gpt4 book ai didi

html - 在底部对齐文本

转载 作者:太空宇宙 更新时间:2023-11-03 22:49:59 25 4
gpt4 key购买 nike

我无法对齐底部的文本。

.container {
margin: auto;
border-radius: 25px;
width: 320px;
height: 480px;
background-color: lightgrey;
background-image: url("https://raw.githubusercontent.com/zumartic/calculator/master/calculator.jpg");
box-shadow: 10px 10px 5px #888888;
}
.head {
width: 320px;
height: 45px;
color: yellow;
font-size: 200%;
font-weight: bold;
text-align: center;
}
.display1 {
width: 320px;
height: 45px;
font-size: 200%;
font-weight: bold;
margin-left: -5px;
text-align: right;
}
.display2 {
width: 320px;
height: 90px;
}
#D2-content {
width: 320px;
font-size: 200%;
word-wrap: break-word;
font-weight: bold;
text-align: right;
margin-left: -1px;
vertical-align: bottom;
}
<div class="container">
<div class="head" id="head">FCC Calculator</div>
<div class="display1" id="display1"></div>
<div class="display2" id="display2">
<div id="D2-content">0</div>
</div>
<hr>
<div class="button-item" id="CE">CE</div>
<div class="button-item" id="C">C</div>
<div class="button-item"></div>
<div class="button-item"></div>
<div class="button-item" id="7">7</div>
<div class="button-item" id="8">8</div>
<div class="button-item" id="9">9</div>
<div class="button-item" id="divide">/</div>
<div class="button-item" id="4">4</div>
<div class="button-item" id="5">5</div>
<div class="button-item" id="6">6</div>
<div class="button-item" id="multiply">*</div>
<div class="button-item" id="1">1</div>
<div class="button-item" id="2">2</div>
<div class="button-item" id="3">3</div>
<div class="button-item" id="minus">-</div>
<div class="button-item" id="0">0</div>
<div class="button-item" id="point">.</div>
<div class="button-item" id="equal">=</div>
<div class="button-item" id="plus">+</div>
</div>

我想先对齐 D2-content 元素中的文本。我已经尝试使用表格并且可以在底部对齐,但是自动换行不再起作用。有什么建议吗?

最佳答案

position:absolute 添加到您要移动的内容。并将 position:relative 添加到父元素。

.container {
margin: auto;
border-radius: 25px;
width: 320px;
height: 480px;
background-color: lightgrey;
background-image: url("https://raw.githubusercontent.com/zumartic/calculator/master/calculator.jpg");
box-shadow: 10px 10px 5px #888888;
}

.head {
width: 320px;
height: 45px;
color: yellow;
font-size: 200%;
font-weight: bold;
text-align: center;
}

.display1 {
width: 320px;
height: 45px;
font-size: 200%;
font-weight: bold;
margin-left: -5px;
text-align: right;
}

.display2 {
width: 320px;
height: 90px;
position:relative;
}

#D2-content {
width: 320px;
font-size: 200%;
word-wrap: break-word;
font-weight: bold;
text-align: right;
margin-left: -1px;

position:absolute;
bottom:0;
}
<div class="container">
<div class="head" id="head">FCC Calculator</div>
<div class="display1" id="display1"></div>
<div class="display2" id="display2"><div id="D2-content">0</div></div><hr>
<div class="button-item" id="CE">CE</div>
<div class="button-item" id="C">C</div>
<div class="button-item"> </div>
<div class="button-item"> </div>
<div class="button-item" id="7">7</div>
<div class="button-item" id="8">8</div>
<div class="button-item" id="9">9</div>
<div class="button-item" id="divide">/</div>
<div class="button-item" id="4">4</div>
<div class="button-item" id="5">5</div>
<div class="button-item" id="6">6</div>
<div class="button-item" id="multiply">*</div>
<div class="button-item" id="1">1</div>
<div class="button-item" id="2">2</div>
<div class="button-item" id="3">3</div>
<div class="button-item" id="minus">-</div>
<div class="button-item" id="0">0</div>
<div class="button-item" id="point">.</div>
<div class="button-item" id="equal">=</div>
<div class="button-item" id="plus">+</div>
</div>

关于html - 在底部对齐文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40396576/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com