test2< /div>
Reply to discussion (solution)
test2
text-align: center
#div2{
text-align:center;
}
It’s all said and done, haha.
You can also add a link-height: line height
You can center it horizontally and vertically
test2< ;/div>
That’s not what I mean. I want to test2. In the first div, the outermost div is centered and aligned
< div id="div2" style="text-align: center;">test2
That’s not what I mean. I want test2, which is the outermost div in the first div. Center alignment
Then put div2 width:100%;
test2
test2
That's not what I meant. To test2, in the first div, the outermost div is centered and aligned
Then put div2 width:100%;
test2
test1 Will it be affected?
No, div2 width: 100%; usually displays
on a separate line. No, div2 width:100%; usually displays
on a separate line. Agree with LS. Can meet LZ's requirements. The first div is aligned by default, while the second div is displayed in the middle because of text-align:center, and the width is 100%, so it has the illusion of being centered in the first layer of divs
It makes sense upstairs
If you add a
tag outside div2, you can also achieve this effect Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn