gpt4 book ai didi

html - 无法设置 div 的正确大小

转载 作者:行者123 更新时间:2023-11-28 15:40:38 25 4
gpt4 key购买 nike

我有两个相邻的 div,它们都有父 div。我的第二个 div 有 .redBlock 类,但它只是按符号长度制作背景。如何使该 div 大小与 parent 的 div 大小相似。因为我需要背景像下面的图片一样。 Cross 也意味着红色背景。 enter image description here

<html>
<head>
<title>Phoneblock</title>
</head>

<body>
<div class="phoneBlock blockContainer">
<div class="block1">
<img class="phone picture" src="phonicon.jpg" alt="phone">
<span class="phoneNumber semiBold"> phone</span>
</div>
<div class="redBlock block2">
<span class="upperCase simpleTextColor tahoma">Block</span>
</div>
</div>



</body>
<style type="text/css">

.pic{

}
.phoneBlock{
height: : 500px;
border:1px solid black;
}

.phoneNumber{
color: #d81e04;
}


.upperCase{
text-transform: uppercase;
}

.redBlock{
height: 90px;
background-color: #d81e04;
}

.simpleTextColor{
color:#ffffff;
}

@font-face {
font-family: SemiBold;
src: url("MyriadPro-Semibold.otf") format("opentype");
}


@font-face {
font-family: BlackIt;
src: url("MyriadPro-BlackIt.otf") format("opentype");
}


.semiBold{
font-family: SemiBold;
}

.blackIt{
font-family: BlackIt;
}
.tahoma{
font-family: Tahoma;
}

.blockContainer{
text-align:center;
}
.block1, .block2{
display:inline;
}


</style>
</html>

最佳答案

在父级设置display:flex

编辑

how to put "BLOCK" word to bottom?

.redBlock 中设置 display:flex 并在子 span 中设置 align-self:flex-end/p>

.phoneBlock {
border: 1px solid black;
display: flex;
justify-content: center/* align content horizontally */
}

.phoneBlock>div {
margin: 0 5px;
}

.phoneNumber {
color: #d81e04;
}

.upperCase {
text-transform: uppercase;
}

.redBlock {
display: flex;
background-color: #d81e04;
}

.redBlock span {

align-self: flex-end
}

.simpleTextColor {
color: #ffffff;
}

img {
vertical-align: bottom;
max-width: 100%
}
<div class="phoneBlock blockContainer">
<div class="block1">
<img class="phone picture" src="//placehold.it/90x90" alt="phone">
<span class="phoneNumber semiBold"> phone</span>
</div>
<div class="redBlock block2">
<span class="upperCase simpleTextColor tahoma">Block</span>
</div>
</div>

关于html - 无法设置 div 的正确大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43913630/

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