php - 在同一选项卡中水平显示 WooCommerce 产品描述和附加信息
问题描述
我无法正确显示我的产品页面。
我希望尝试在我的产品页面上获得这样的结果。(同一选项卡中水平的描述和属性)
正如您在图片中看到的,描述位于左侧,属性显示在右侧。
在我的网站上,我目前已删除属性选项卡并将其嵌套在描述下方,在我的以下代码中使用此代码functions.php
:
add_filter( 'woocommerce_product_tabs', 'exetera_custom_product_tabs', 98 );
function exetera_custom_product_tabs( $tabs ) {
// Custom description callback.
$tabs['description']['callback'] = function() {
global $post, $product;
// Display the content of the Description tab.
the_content();
// Display the heading and content of the Additional Information tab.
echo '<h2>Specifications</h2>';
do_action( 'woocommerce_product_additional_information', $product );
};
// Remove the additional information tab.
unset( $tabs['additional_information'] );
return $tabs;
}
只是无法弄清楚如何让它水平放置在彼此旁边。
任何帮助将不胜感激,在此先感谢!
解决方案
您必须将选项卡的内容包装在 div 中,然后使用 CSS 对齐/设置样式。但是,这取决于主题,因此我的回答被简化为绝对基础。
add_filter( 'woocommerce_product_tabs', 'exetera_custom_product_tabs', 98, 1 );
function exetera_custom_product_tabs( $tabs ) {
// Custom description callback.
$tabs['description']['callback'] = function() {
global $post, $product;
echo '<div class="description left" style="float:left;width:49%;">';
// Display the content of the Description tab.
the_content();
echo '</div>';
// Display the heading and content of the Additional Information tab.
echo '<div class="specifications right" style="float:right;width:49%;">';
echo '<h2>Specifications</h2>';
do_action( 'woocommerce_product_additional_information', $product );
echo '</div>';
};
// Remove the additional information tab.
unset( $tabs['additional_information'] );
return $tabs;
}
推荐阅读
- python - pygame 代码认为我输入了一个字符串,但它应该是一个表面
- amazon-web-services - 从 AWS S3 存储桶并行下载文件
- pandas - 在熊猫数据框中删除空值后出现键错误
- spring-boot - Spring Security 使用有效的客户端 ID 和客户端密码抛出 401 错误
- c# - 我想在我的 C# 项目中使用 System.Threading 加快计算速度
- sql - 我的 TO_DATE 似乎无法正常运行
- html - 需要修复将鼠标悬停在按钮上的问题?
- java - 使用循环后,我的扫描仪问题加倍,出现异常错误
- json - 从 Firebase 获取原始 JSON 到 Flutter
- javascript - Bootstrap 模态轮播重复内容