gpt4 book ai didi

html - 文本在 div 中居中,另一个 div 在左边,右边框

转载 作者:太空宇宙 更新时间:2023-11-04 02:27:43 25 4
gpt4 key购买 nike

抱歉,我不知道如何描述帖子标题。我想使用 html/css 实现类似屏幕截图的效果:

screen

这将成为我的专栏的某种标题/标题。我希望 ABC 在蓝色边框中垂直和水平居中。此外,红点(我想放小 img)应该垂直居中,图像右侧应该有 1px 粗灰线。如何做到这一点?

我试过类似的方法,但是行太短了:

<div style="background: #75d0ff;">

<div style="border-right: 1px solid gray; padding: 20px; display: inline; height: 100%;">
<img src="css/img/dot.png">
</div>

<div class="border-content" style="display: inline">
<p class="text-center">ABC</p>
</div>
</div>

最佳答案

我认为这是正确的方法:

#container {
position: relative;
text-align: center;
height:50px;
background-color: #67CDFB;
width: 200px;
}

#textPusher {
width: 100%;
height:35%;
}
#imgContainer{
width: 20%;
height: 100%;
position: absolute;
top:0;
border-right:1px solid red;
}

#imgContainer img{
position: absolute;
top: 10px;
left: 10px;
width:calc(100% - 20px);
height: calc(100% - 20px);

}
<div id="container">

<div id="textPusher"></div>
<div id="textContainer">abc</div>
<div id="imgContainer"><img src="http://lorempixel.com/400/200/" alt=""></div>



</div>

关于html - 文本在 div 中居中,另一个 div 在左边,右边框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37060337/

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