css相對定位絕對定位和內容居中詳解
阿新 • • 發佈:2019-01-02
<style type="text/css">
.container {
width: 200px;
height: 200px;
background-color: red;
position: relative;
margin: 0 auto;
}
.div1 {
width: 100px;
height: 120px;
background-color: darkgreen;
float: left;
position: absolute;
bottom: 0;
text-align: center;
line-height: 120px;
}
.div2 {
width: 100px;
height: 100px;
background-color: darkgrey;
position: absolute;
margin-left: 100px;
bottom: 0px;
float: left;
}
.span1{
position: relative;
text-align: center;
background-color: greenyellow;
}
</style>
</head>
<body>
<div class="container">
<div class="div1"><span class="span1">13</span></div>
<div class="div2">23</div>
</div>
.container {
width: 200px;
height: 200px;
background-color: red;
position: relative;
margin: 0 auto;
}
.div1 {
width: 100px;
height: 120px;
background-color: darkgreen;
float: left;
position: absolute;
bottom: 0;
text-align: center;
line-height: 120px;
}
.div2 {
width: 100px;
height: 100px;
background-color: darkgrey;
position: absolute;
margin-left: 100px;
bottom: 0px;
float: left;
}
.span1{
position: relative;
text-align: center;
background-color: greenyellow;
}
</style>
</head>
<body>
<div class="container">
<div class="div1"><span class="span1">13</span></div>
<div class="div2">23</div>
</div>