2017-05-07 17 views
-3

你能否請幫助獲取使用CSS的div下面的輸出。如果你可以定製更多,它會更充分的幫助。如何使用邊框來獲得低於div的設計

enter image description here

+1

你嘗試過這麼遠嗎? – hrust

+0

歡迎使用stackoverflow。請,你能提供一些你的具體問題的代碼嗎?這可以證明你嘗試了多遠,它會幫助其他成員更好地理解你的問題,當時,你會給他們一個你的問題的背景。請檢查以下鏈接:https://stackoverflow.com/help/mcve和https://stackoverflow.com/help/how-to-ask –

回答

0

你可以做這樣的事情使用Flexbox的:

body { 
 
    padding: 5%; 
 
} 
 

 
.back-div { 
 
    width: 500px; 
 
    height: 200px; 
 
    border: 1px solid black; 
 
    display: flex; 
 
    flex-direction: column; 
 
    align-items: center; 
 
} 
 

 
.blue { 
 
    background: blue; 
 
    width: 400px; 
 
    height: 100px; 
 
    margin-bottom: 100px; 
 
    flex-shrink: 0; 
 
    margin-top: -45px; 
 
    text-align: center; 
 
} 
 

 
.yellow { 
 
    background: yellow; 
 
    width: 400px; 
 
    height: 100px; 
 
    flex-shrink: 0; 
 
    text-align: center; 
 
}
<div class="back-div"> 
 
    <div class="blue"> 
 
    <h1> Text 1</h1> 
 
    </div> 
 

 
    <div class="yellow"> 
 
    <h1> Text 2</h1> 
 
    </div> 
 
</div>

小提琴:https://jsfiddle.net/jdzgsxg4/