2016-04-14 69 views
1

我是CSS的新手,我對每個不同元素的水平定位都很糾結。我試圖將3個元素放置在圖片上顯示的文本段落的同一行上。有什麼建議麼 ?元素和文本CSS3定位

enter image description here

.planning { 
 
    position: relative; 
 
    top: 20px; 
 
} 
 
.circle1, 
 
.circle2, 
 
.circle3 { 
 
    width: 43px; 
 
    height: 43px; 
 
    background-color: #add136; 
 
    border-radius: 25px; 
 
    display: inline-block; 
 
} 
 
.circle1 { 
 
    float: left; 
 
} 
 
.circle2 { 
 
    text-align: center; 
 
} 
 
.circle3 { 
 
    float: right; 
 
}
<div class="planning"> 
 
    <div class="circle1"> 
 
    <p>Simple</p> 
 
    </div> 
 
    <div class="circle2"> 
 
    <p>Transparent</p> 
 
    </div> 
 
    <div class="circle3"> 
 
    <p>Collaborative</p> 
 
    </div> 
 
</div>

回答

1

改變你的CSS這樣的:

.planning{ 

    position: relative; 
    top: 20px; 
} 

.planning div{ 
    display:inline-block; 
    width:33%; 
    text-align:center; 
    position: relative; 
    border-bottom:1px solid silver; 
    padding-bottom:15px; 
} 
.planning div:hover{ 
    border-bottom: 1px solid #88be14; 
} 

.planning div:before{ 
    background: silver ; 
    border-radius:50%; 
    color:white; 
    position:absolute; 
    left:10px; 
    width: 43px; 
    height: 43px; 
    padding:10px; 
    font-size:15pt; 
    -moz-box-sizing: border-box; 
    -webkit-box-sizing: border-box; 
    box-sizing:border-box; 
} 

.planning div:hover:before{ 
    background: #88be14 ; 
} 

.circle1:before{ 
    content:"1"; 
} 

.circle2:before{ 
    content:"2"; 
} 

.circle3:before{ 
    content:"3"; 
} 

編輯樣品:

https://jsfiddle.net/zu86kgrr/4/

+0

感謝您的建議! – l2Code

+0

@ l2Code如果我幫你,請接受答案。 –