【发布时间】:2014-03-12 16:59:04
【问题描述】:
刚为我的班级交了一份编程作业,并在与老师交谈时,他告诉我不允许使用我的图像居中。他说我必须使用 id 和 class,然后在样式表/CSS 中居中。这对我来说毫无意义,当我使用内联时它工作得很好,但我已经尝试了我所知道的一切以在样式表中居中并且没有任何效果。我从我的代码中附上了 2 个示例:
这对居中图像非常有效,但教授说这是不允许的:
<h5>Back View</h5>
<div style="text-align: center"/>
<a href="BackViewT-Shirt.html" target="_blank">
<img src="http://i1293.photobucket.com/albums/b581/AlaskanAdventureApparel/photo1_zpsff666fce.jpg" height="400" width="300" alt="Back View Alaskan Adventure T-Shirt"/>
</a>
然后尝试使用 id 和 class,但没有任何效果,尝试将标题和图像居中:
HTML:
<h5 class="center">Back View</h5>
<a href="BackViewT-Shirt.html" target="_blank">
<img src="http://i1293.photobucket.com/albums/b581/AlaskanAdventureApparel/photo1_zpsff666fce.jpg" height="400" width="300" alt="Back View Alaskan Adventure T-Shirt"/>
</a>
样式表:
.center {
text.align: center;
}
【问题讨论】:
标签: html css image class centering