2014-12-17 26 views
5

Kutu gölgesini, div'in yalnızca yarısına uygulamak istiyorum. Google'da çok arama yaptım, ancak başarısız oldu. İşte basit kutu gölgesi için kod.CSS3 Kutunun yarısı için kutu gölgesi

<style type="text/css"> 
    div{ 
     width: 200px; 
     height: 200px; 
     text-align: center; 
     background-color: gray; 
     margin: auto; 
     font-size: 30px; 
     box-shadow: 0 100px 5px 5px; 
    } 
</style> 

<div>Sometimes by losing a battle you find a new way to win the war.</div> 

Kodlu:

enter image description here

Gerekli: Önceden teşekkür

enter image description here

varil ...

cevap

10

Bunu başarmak için box-shadow ürününü :after: sözde öğeye uygulayabilirsiniz.

div { 
 
    width: 200px; 
 
    height: 200px; 
 
    text-align: center; 
 
    background-color: gray; 
 
    margin: auto; 
 
    font-size: 30px; 
 
    position: relative; 
 
} 
 
div:after { 
 
    position: absolute; 
 
    content: ''; 
 
    width: 100%; 
 
    height: 50%; /* Half of the original height */ 
 
    top: 0; 
 
    left:0; 
 
    box-shadow: 0 100px 5px 5px; 
 
    z-index: -1; 
 
}
<div>Sometimes by losing a battle you find a new way to win the war.</div>

+4

O Evet. Hey dostum! Dışarı gel. Teşekkürler dolu bir tren kapınıza geliyor. Teşekkürler ... –

+0

@ Felix-Robinchik - Rica ederim! :) –

İlgili konular