gpt4 book ai didi

html - 如何更改同一行元素的位置

转载 作者:行者123 更新时间:2023-11-28 00:35:47 25 4
gpt4 key购买 nike

我有一个包含 3 个元素的 block - 最小值、产品库存、最大值。

我需要做的就是找到一种方法,使产品库存处于两个值的中间。

我的猜测是问题应该出在这些行上:

<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)

Using Flex wrong even worst

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>

最佳答案

CSS flexbox 将帮助您轻松实现这一目标。

Check this fiddle

Read about CSS flex

.value-container{
width: 600px;
display: flex;
justify-content: space-between;
}

更新:

确保从 wcl-progress-meter div 中取出跨度并将其放入 ma​​x 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;
}

关于html - 如何更改同一行元素的位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56348745/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com