我有一个由3个要素组成的区块-最小值,产品库存,最大值。
我要做的就是找到一种方法来对齐两个值之间的中间产品库存。
我的猜测是问题应该出在以下几行上:
<style>
.inline-parent{text-align:center;}
.inline-block{display:inline-block;margin-right:10px;}
</style>
<div class="max inline-parent">
<div class="inline-block"><?php echo $tickets_sold;?></div>
<div class="inline-block"><?php echo $max_tickets;?></div>
</div>
My browser renders the file like this:(screenshot)
Inspect of the element shows this: (screenshot)
CSS-
.wcl-progress-meter meter::-webkit-meter-suboptimum-value {
box-shadow: 0 5px 5px -5px #999 inset;
background: #cb132b;
display:inline-block;
}
.wcl-progress-meter .zero {
display: inline-block;
position: absolute;
top: -100%;
}
.wcl-progress-meter .min {
display: inline-block;
position: absolute;
top: -100%;
}
.wcl-progress-meter .max {
display: inline-block;
position: absolute;
top: -100%;
right: 0;
}
我尝试编辑代码的PHP文件
$max_tickets = $product->get_max_tickets();
$tickets_sold = wc_get_stock_html( $product );
<div class="wcl-progress-meter <?php if($product->is_max_tickets_met()) echo 'full' ?>">
<progress max="<?php echo $max_tickets ?>" value="<?php echo $lottery_participants_count ?>" low="<?php echo $min_tickets ?>"></progress></br>
<span class="zero">0</span>
<style>
.inline-parent{text-align:center;}
.inline-block{display:inline-block;margin-right:10px;}
</style>
<div class="max inline-parent">
<div class="inline-block"><?php echo $tickets_sold;?></div>
<div class="inline-block"><?php echo $max_tickets;?></div>
</div>
答案 0 :(得分:1)
CSS flexbox将帮助您轻松实现这一目标。
.value-container{
width: 600px;
display: flex;
justify-content: space-between;
}
更新:
请确保您从 wcl-progress-meter div中删除了跨度,并将其放在 max div
内您也可以摆脱 inline-block 类。请参阅下面的代码。
<span class="zero">0</span>
PHP:
<div class="max">
<span class="zero">0</span>
<div><?php echo $tickets_sold;?></div>
<div><?php echo $max_tickets;?></div>
</div>
CSS:
.max{
display: flex;
justify-content: space-between;
}
更新:2(如果删除绝对位置,则CSS应该会在下面起作用)
.wcl-progress-meter meter::-webkit-meter-suboptimum-value {
box-shadow: 0 5px 5px -5px #999 inset;
background: #cb132b;
display:inline-block;
}
.wcl-progress-meter .zero {
/* try removing the CSS */
}
.wcl-progress-meter .min {
/* try removing the CSS */
}
.wcl-progress-meter .max {
display: flex;
justify-content: space-between;
}