[英]Getting text to display to the left and right of a text-align: center
Alright so I have 好吧,我有
<div id='1'></div>
<div id='2'></div>
<div id='3'></div>
Only one word will go into each div. 每个div只有一个单词。 I want the width of each div to be auto
我希望每个div的宽度都是自动的
and I want to word from #2 to be in the middle of the screen using text-align: center; 我希望使用text-align:center从#2中的单词出现在屏幕中间; with the word in #1 being displayed directly to the left of #2 and the #3 directly to the right of #2.
将#1中的单词直接显示在#2的左侧,将#3直接显示在#2的右侧。
I have been trying different css for a while, but to no effect. 我一直尝试不同的CSS,但没有效果。
Hoping someone has a simple answer. 希望有人有一个简单的答案。
Simply float all the divs to the left. 只需将所有div向左浮动即可。 They will display in order.
它们将按顺序显示。
<style>
.my-dvis {
float:left;
width:33.33%;
margin:0;
padding:0;
border:none;
}
</style>
<div class="my-divs"></div>
<div class="my-divs"></div>
<div class="my-divs"></div>
您是否尝试向右浮动id = 1并向右浮动id = 3?
I suggest you to use <span>
tag instead of using div
tag,because div
have a property of taking width 100%
. 我建议你使用
<span>
标签而不是使用div
标签,因为div
具有width 100%
的属性。
Or else if you want to use div tag then use in the following manor 或者如果你想使用div标签,那么请使用以下庄园
<div id='1'></div>
<div id='2'></div>
<div id='3'></div>
<style>
div{
float:left;
width:33.3%;
}
</style>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.