Javascript 两个水平对齐的div和一个垂直对齐的内部div
在这里的示例中,我试图垂直对齐第二个div。一个div中的文本可以变化,可以是1-50个字符。第二个div可以是4-7个字符,但如果一个div中的文本较大,则需要垂直对齐 html 使用显示表 HTML 喜欢Javascript 两个水平对齐的div和一个垂直对齐的内部div,javascript,html,css,Javascript,Html,Css,在这里的示例中,我试图垂直对齐第二个div。一个div中的文本可以变化,可以是1-50个字符。第二个div可以是4-7个字符,但如果一个div中的文本较大,则需要垂直对齐 html 使用显示表 HTML 喜欢 <div class="wrap"> <div class="two">result</div> <div class="one">This is a long string This is a long string Th
<div class="wrap">
<div class="two">result</div>
<div class="one">This is a long string This is a long string This is a long string This is a long string This is a long string This is a long string This is a long string This is a long string This is a long string</div>
</div>
div.wrap
{
width: 200px;
}
div.one {
border: 1px solid #AAAAAA;
white-space: normal;
word-wrap: break-word;
}
div.two {
background-color: #7bbf7b;
float: right;
}
<div class="wrap">
<div class="one">This is a long string This is a long string This is a long string This is a long string This is a long string This is a long string This is a long string This is a long string This is a long string</div>
<div class="two">result</div>
</div>
div.wrap
{
width: 200px;
display: table;
}
div.one {
border: 1px solid #AAAAAA;
white-space: normal;
word-wrap: break-word;
display: table-cell;
}
div.two {
background-color: #7bbf7b;
display: table-cell;
vertical-align: middle;
}