gpt4 book ai didi

html - 将容器与 3 个 div 水平对齐

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

我试过用 3 个 div 制作一个容器,使三个盒子水平排列。中心框在顶部和底部与左侧框不对齐,第三个框远低于前两个框。我对此进行了一些研究,但我尝试进行的更改并没有改变这一点。

非常感谢!

Link that shows photo of final page and the issue that I am having

HTML代码:

<div class="container">
<div class="left">
<p>
Tarata Community Engagement
</p>
<a href="http://www.onlythebridge.com/?page_id=28" class="tarata" target="_blank"><img src="tarata.jpg" width="400" height="267" alt="Tarata Community Engagement Project" /></a></div>
<div class="center">
<p>
Santa Rosa Community Engagement
</p>
<img src="santa-rosa.jpg" width="400" height="267" alt="Santa Rosa Community Engagement Project" />
</div>
<div class="right">
<p>
Our histories are unique. The places that we root ourselves, the communities that we are part of, and the ways those relationships change over time are both personal and shared experiences.
<br><br>
What place/s are meaningful to you? Why? <br>
What are your roots? What do they mean to you in your life?<br>
How do you carry meaningful places and your roots with you? <br>
What is home to you? <br>
Have you left any places or communities behind, what's that like?
</p></div>
</div>

xhtml 文档中的样式代码:

.container {
width:100%;
height:100%;
text-align:left;

}
.left {
float: left;
margin-left:100px;
max-width: 300px;

}
.center {
float: center;
margin-left: 650px;
max-width: 300px;

}
.right {
float: right;
margin-right: 100px;
max-width: 410px;

}

最佳答案

这有帮助吗?您可以像尝试做的那样使用 flex 对齐三列。 Flex 在 IE 中不起作用 ( http://caniuse.com/#feat=flexbox )

.container {
/* Important for columns */
display: -webkit-flex;
display: flex;
flex-wrap:wrap; /*EDIT: will wrap into 1 column if screen small */
}

.item {
/* Important for columns */
flex: 1 1 0;
border: 3px solid #808080;
height: 52px;
padding: 10px;
}


/* Remove duplicate borders */

.item-2 {
border-left: none;
border-right: none;
}
<div class="container">

<div class="item item-1">
Image or text here - 1
</div>

<div class="item item-2">
Image or text here - 2
</div>

<div class="item item-3">
Image or text here - 3
</div>

</div>

关于html - 将容器与 3 个 div 水平对齐,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43310472/

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