gpt4 book ai didi

css - 如何恢复宽度 :100% to just the length of the text?

转载 作者:太空宇宙 更新时间:2023-11-04 01:44:57 24 4
gpt4 key购买 nike

蓝色背景是 100% 宽度,我只希望它与文本一样宽。

https://codepen.io/TylerL-uxai/pen/gRxMqG

.ux {
position: absolute;
bottom: 0;
left: 0;
right: 0;
margin: 0 auto;
background: #3c99cd;
background: rgba(60, 153, 205, 0.85);
color: white;
}
<div class="header-img-ux">
<h2 class="ux">User Experience Design</h2>
</div>

最佳答案

.ux {
margin:0;
position: absolute;
bottom: 0;
left: 0;
}
.ux span {
background: #3c99cd;
background: rgba(60, 153, 205, 0.85);
color: white;
}
<div class="header-img-ux">
<h2 class="ux"><span>User Experience Design</span></h2>
</div>

关于css - 如何恢复宽度 :100% to just the length of the text?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44743742/

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