gpt4 book ai didi

html - CSS 将 3 个元素一一对齐

转载 作者:行者123 更新时间:2023-11-28 13:15:41 26 4
gpt4 key购买 nike

我需要将下面给出的三个元素水平而不是垂直对齐...这是当前文件...我该怎么做?

HTML:

    <div id="banner">
<div class="IE-banner">
<div id="go-lang">
<p> This will contain google language </p>
</div>
<div id="go-search">
<p> This will contain google search </p>
</div>
<div id="go-search">
<p> This will contain facebook links </p>
</div>
</div>
</div>

CSS:

#banner{ 
width:900px;
height:75px;
background-color:Red;
color:White;
font-size:10px;
font-weight:bold;
position:relative;
}

div.IE-banner{
position:absolute;
vertical-align:middle;
top:20px;
right:10px;
font-size:medium;
}

enter image description here

最佳答案

将你想要的元素排成一行:display:inline-block

.IE-banner div {
display: inline-block;
}

不过,为了更有条理,我会为您想要内联的所有元素添加一个类。并且只修改那个类。

<div id="banner">
<div class="IE-banner">
<div id="go-lang" class="inline">
<p> This will contain google language </p>
</div>
<div id="go-search" class="inline">
<p> This will contain google search </p>
</div>
<div id="go-search" class="inline">
<p> This will contain facebook links </p>
</div>
</div>
</div>

CSS:

.inline {
display:inline-block;
}

关于html - CSS 将 3 个元素一一对齐,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15053000/

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