Html 将图像在 div 中向右对齐
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7745232/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
align images to right in a div
提问by Ryan
i have something like:
我有类似的东西:
<div id="read_more_right">
<a href="1"><img src='1'></a>
<a href="1"><img src='1'></a>
<a href="1"><img src='1'></a>
</div>
i want to align all those images to the right in a div
我想将所有这些图像在 div 中向右对齐
I use this
我用这个
#read_more_right div
{
align: right;
}
but it doesn't work. How can I allign this to the right?
但它不起作用。我怎样才能把它向右对齐?
回答by NCode
It's text-align: right;instead of only align
它是text-align: right; 而不仅仅是对齐
回答by Galled
You could use:
你可以使用:
#read_more_right a{
float:right;
clear:right;
}
回答by vitaminjeff
If you're trying to select your div based on ID you need to declare it in the following fashion:
如果您尝试根据 ID 选择 div,则需要按以下方式声明它:
div#read_more_right { text-align: right; }
div#read_more_right { 文本对齐:右;}
回答by Agustin Meriles
I'm not really sure, but I think your syntax is wrong. Try this; it worked for me:
我不太确定,但我认为你的语法是错误的。尝试这个; 它对我有用:
div#read_more_right
{
text-align: right;
}
回答by Tom
Try text-align: right;
-- you may need to set an explicit width on the div in some cases.
尝试text-align: right;
- 在某些情况下,您可能需要在 div 上设置显式宽度。
回答by Sam Axe
try text-align: right;
尝试 text-align: right;
I know its not text.. but that's the one you want.
我知道它不是文本……但那是你想要的。
回答by saritonin
See also: What is the best way to left align and right align two div tags?for some answers to a similar problem and thisfor a good overview of float and alignment properties.
另请参阅:左对齐和右对齐两个 div 标签的最佳方法是什么?对于类似问题的一些答案,这是对浮动和对齐属性的良好概述。