2017-09-26 105 views
0

如何在下面的代碼中透明的「紅色」背景?純粹的css對話

https://codepen.io/anon/pen/JrEwyy

.from-me { 
    position:relative; 
    padding:10px 20px; 
    color:white; 
    background:#0B93F6; 
    border-radius:25px 25px 0 25px; 
    float: right; 

    &:before { 
     content:""; 
     position:absolute; 
     z-index:-1; 
     bottom:-2px; 
     right:-7px; 
     height:20px; 
     border-right:20px solid #0B93F6; 
     border-bottom-left-radius: 16px 14px; 
     -webkit-transform:translate(0, -2px); 
    } 

    &:after { 
     content:""; 
     position:absolute; 
     z-index:1; 
     bottom:-2px; 
     right:-56px; 
     width:26px; 
     height:20px; 
     background:red; 
     border-bottom-left-radius: 10px; 
     -webkit-transform:translate(-30px, -2px); 
    } 
} 

,因爲我想在身體使用背景圖片,我必須隱藏的紅色背景

回答

0

這是一種不同的方法,您的問題。我不是從藍色框中刪除某些部分,而是以另一種方式創建了自定義形狀。我希望你正在努力實現這樣的事情。

.square{ 
 
    width:100px; 
 
    height:100px; 
 
    overflow:hidden; 
 
    position:relative; 
 
    float: left 
 
} 
 
.round{ 
 
    width:200px; 
 
    height:200px; 
 
    border: solid 100px red; 
 
    position: absolute; 
 
    bottom: -100px; 
 
    left: -100px; 
 
    border-radius: 50%; 
 
}
<div class="square"> 
 
    <div class="round"></div> 
 
</div>

+0

這不是所希望的結果。 – VXp

2

不要使用兩個僞元素,打造捲曲,用一用一徑向漸變。

body { 
 
    font-family: "Helvetica Neue"; 
 
    font-size: 20px; 
 
    font-weight: normal; 
 
    background-image: url("https://storage.googleapis.com/gweb-uniblog-publish-prod/images/Background.2e16d0ba.fill-1422x800.jpg"); 
 
} 
 

 
section { 
 
    max-width: 450px; 
 
    margin: 50px auto; 
 
} 
 

 
section div { 
 
    max-width: 255px; 
 
    word-wrap: break-word; 
 
    margin-bottom: 20px; 
 
    line-height: 24px; 
 
} 
 

 
.clear { 
 
    clear: both; 
 
} 
 

 
.from-me { 
 
    position: relative; 
 
    padding: 10px 20px; 
 
    color: white; 
 
    background: #0B93F6; 
 
    border-radius: 25px 25px 0 25px; 
 
    float: right; 
 
} 
 

 
.from-me:before { 
 
    content: ""; 
 
    position: absolute; 
 
    z-index: -1; 
 
    width: 14px; 
 
    height: 14px; 
 
    background: radial-gradient(circle at top right, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0) 14px, #0b93f6 14px); 
 
    bottom: 0; 
 
    left: 100%; 
 
}
<section> 
 
    <div class="from-me"> 
 
    <p>Hey there! What's up?</p> 
 
    </div> 
 
</section>