对齐三个 div:其中一个包含图像,另外两个包含文本
我正在尝试并排对齐三个 div。中心 div 包含带有图像的 href,可扩展链接以编辑文本。问题是我无法垂直对齐这些 div 的内容。左、右和中心 div 内容都应该在中间垂直对齐,如下所示:
[右]
[左][中][右]
[右]
它也可能看起来像:
[左]
[左] [右]
[左][中][右]
[左] [右]
[左]
但现在看起来像:
[左][中][右]
[左] [右]
[左]
编辑内容 div 位于
这是到目前为止的代码:
<div id="search-result" class="accordion">
<div class="search-result-left">
<p>CEPT, Conference Européenne des Adminidstra-</p>
<p>tion Despostes et des Télécommunications</p>
</div>
<div class="search-result-right">
<p>Evropsko združenje poštnih in telekomunikaci-</p>
<p>jskih organizacij</p>
</div>
<div class="search-result-center">
<a href="#" class="acc"><img src="CSS/images/arrow_wr.gif"/></a>
</div>
<div class="edit-content">
<p><a href="#">edit</a> -
<a href="#">comment</a> -
<a href="#">translate</a>
</p>
</div>
</div>
和 css:
#all-search-results {
font-size: 14px;
color: #000000;
width: 730px;
margin: 0 auto;
line-height: 4px;
}
.search-result-left {
text-align: right;
float: left;
width: 335px;
}
.search-result-center {
text-align: center;
margin: 0 auto;
width: 60px;
}
.search-result-center img{
vertical-align: bottom;
}
.search-result-right {
text-align: left;
float: right;
width: 335px;
}
.edit-content{
color: #669900;
margin-top: 20px;
}
.edit-content a {
color: #669900;
}
I am trying to align three divs side by side. The center div contains a href with image, that expands links to edit text. The problem is that I am unable to verticaly align the contents of those divs. The left, right and center div contents should all be verticaly aligned in the middle like:
[right]
[left] [center] [right]
[right]
It might also look something like:
[left]
[left] [right]
[left] [center] [right]
[left] [right]
[left]
But now it looks like:
[left] [center] [right]
[left] [right]
[left]
The edit-content div lies
This is the code so far:
<div id="search-result" class="accordion">
<div class="search-result-left">
<p>CEPT, Conference Européenne des Adminidstra-</p>
<p>tion Despostes et des Télécommunications</p>
</div>
<div class="search-result-right">
<p>Evropsko združenje poštnih in telekomunikaci-</p>
<p>jskih organizacij</p>
</div>
<div class="search-result-center">
<a href="#" class="acc"><img src="CSS/images/arrow_wr.gif"/></a>
</div>
<div class="edit-content">
<p><a href="#">edit</a> -
<a href="#">comment</a> -
<a href="#">translate</a>
</p>
</div>
</div>
and css:
#all-search-results {
font-size: 14px;
color: #000000;
width: 730px;
margin: 0 auto;
line-height: 4px;
}
.search-result-left {
text-align: right;
float: left;
width: 335px;
}
.search-result-center {
text-align: center;
margin: 0 auto;
width: 60px;
}
.search-result-center img{
vertical-align: bottom;
}
.search-result-right {
text-align: left;
float: right;
width: 335px;
}
.edit-content{
color: #669900;
margin-top: 20px;
}
.edit-content a {
color: #669900;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
为了居中对齐
div
的内容,我这样做了:To center align the contents of a
div
I've done this:很简单,你必须做一些调整,但你的想法是将它分成三个
部分
中间
然后,您可以在底部
将第一个块浮动到顶部块的右侧,
然后在中间推3块
然后将另一个浮动到底部块内的右侧。
(如果我的代码不起作用,抱歉我没有测试过它,但想法是存在的)
最好将事情分解成我所说的“包装”。
网页
Easy, you're gunna have to do some tweaking but the idea is you split it into three parts
top
middle
Bottom
you can then float the first block over to the right in the top block,
then shove 3 blocks in the middle
then float another one to the right inside the bottom block.
(if my code dosn't work sorry I haven't tested it, but the idea is there)
It's always best to break things up in what I call 'wraps'.
Html
这是一个例子,你可以参考这个
Here is the example you can refer this