【发布时间】:2023-04-04 05:10:01
【问题描述】:
更新:在我的页面顶部,我的图像向左浮动。在它旁边,我有一个文本对齐链接列表:中心;在图像之后,最后一个链接居中,尽管它以 div 为中心,并且不以向左浮动的图像居中。
这里是更新小提琴的链接:https://jsfiddle.net/john_h/ewcsfce9/6/
CSS:
h2 {text-align: center;
color: blue;
}
h2 a {
text-align: center;
}
a.link {
color: #00008A;
text-decoration: underline;
display: inline-block;
}
a.link:hover{
color: orange;
font-size: 150%;
}
div.logo {
float: left;
width: 30%;
}
div.links {
float: right;
width: 70%;
}
HTML:
<div class="logo">
<a href=https://answers.aseba.org/>
<img src="http://www.aseba.org/graphics/ASEBA%20Logosmall.jpg" alt="ASEBA Logo">
</a>
</div>
<div class="links">
<h2>
<strong>
<a class="link" href="https://answers.aseba.org/category/aseba-web">ASEBA-WEB Knowledgebase</a>
</strong>
</h2>
<br>
<h2>
<strong>
<a class="link" href="https://answers.aseba.org/category/aseba-pc">ASEBA-PC Knowledgebase</a>
</strong>
</h2>
<br>
<h2>
<strong>
<a class="link" href="https://answers.aseba.org/category/aseba-network">ASEBA-Network Knowledgebase</a>
</strong>
</h2>
<br>
<h2>
<strong>
<a class="link" href="https://www.youtube.com/channel/UCIzvez_ZzkpM83-kInJX1HQ" target="_blank">ASEBA Support YouTube Channel!</a>
</strong>
</h2>
<br>
<h2>
<strong>
<a class="link" href="https://answers.aseba.org/">Complete ASEBA Knowledgebase</a>
</strong>
<br>
</h2>
</div>
<hr>
我意识到我有几个选择。一种是创建一个“空白”元素,它在图像下方向左浮动,与图像本身的宽度相同。二是把logo改大了。
我怎样才能让链接保持浮动在中心,相对于徽标?
谢谢!
【问题讨论】:
-
您希望徽标位于左侧,链接位于徽标底部的中心吗?
-
我想要左边的图像,并且链接相对于徽标居中...在小提琴中,您注意到前两个链接相对于徽标居中,下面的链接是相对于 div 居中。
-
检查这个并告诉我这是你想要的吗? jsfiddle.net/firnas10/6cLgdmst
-
这是因为div的高度。将 div.logo 的高度设置为 5000px,你就会明白我的意思了。您需要对其进行排序
-
@john_h 请检查我的小提琴它的更新