我想在我的HTML文件的中心做这个:
<a href="kobe1.html"><u style="font-size:10px">click images for more information </u></a>
Run Code Online (Sandbox Code Playgroud)
我试过了
a {
text-align: center;
}Run Code Online (Sandbox Code Playgroud)
<a href="kobe1.html"><u style="font-size:10px">click images for more information </u></a>Run Code Online (Sandbox Code Playgroud)
<center>
<a href="kobe1.html"><u style="font-size:10px">click images for more information </u></a>
</center>Run Code Online (Sandbox Code Playgroud)
和
a {
left: 50%;
}Run Code Online (Sandbox Code Playgroud)
<a href="kobe1.html"><u style="font-size:10px">click images for more information </u></a>Run Code Online (Sandbox Code Playgroud)
但什么都没发生.有谁能够帮我?.
其他答案要么显示出对CSS中文本对齐方式的完全误解,要么完全无法解释它.
在CSS中,有两种主要类型的元素,块(如<div>,<p>和<h1>)和内联(如<span>,<a>和<u>).
你不能text-align: center对内联进行强制转换,因为当你想到它时,它没有任何意义(将一个粗体字放在一堆文本中是什么意思?).
但是,您可以text-align: center在块上进行投射,然后将该块中的所有文本和内联对齐到中心.因此,正确的解决方案是找到最近的块父,或创建一个:
.centered {
text-align: center;
/* On the container */
}
.small {
font-size: 10px;
}Run Code Online (Sandbox Code Playgroud)
<div class="centered">
<a href="whatever"><u class="small">Text here!</u></a>
</div>Run Code Online (Sandbox Code Playgroud)