2013-01-14 15 views
7

सीएसएस एक सामग्री कंटेनर का एक बाएँ और दाएँ किनारों इस छवि की तरह लग रहे बनाने के लिए इस्तेमाल किया जा सकता है? मैं छवि का उपयोग किए बिना ऐसा करने का एक तरीका जानने का प्रयास कर रहा हूं, यदि यह संभव है।सीएसएस घुमावदार ढ़ाल और बॉक्स छाया

image of left and right borders

यहाँ jsFiddle है कि मैं पर काम कर रहा है है। "शीर्ष" वर्ग के लिए सीएसएस कभी भी लागू नहीं होता है। "नीचे" कक्षा के लिए सीएसएस ठीक काम करता प्रतीत होता है।

http://jsfiddle.net/kXuQY/

HTML:

<div class="drop-shadow top bottom"> 
    Content here. 
</div> 

सीएसएस:

.drop-shadow { 
/** Create container. Box-shadow here is to color the inside of the container **/ 
position:relative; 
width:50%; 
background: none repeat scroll 0 0 #FFFFFF; 
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3), 0 0 40px rgba(0, 0, 0, 0.1) inset; 
padding:3em; 
margin: 2em 20px 4em; 
text-align:center 
} 

.top:before, 
.top:after { 
    /** Generate pseudo-elements ('before' and 'after') and push them behind the container box. Position pseudo-elements ('before', and 'after') and give them dimensions **/ 
content:""; 
position:absolute; 
z-index:-1; 
top:20px; 
left:0; 
width:40%; 
height:1em; 
max-width:150px; 
-webkit-box-shadow:0 15px 10px rgba(0, 0, 0, 0.7); 
-moz-box-shadow:0 15px 10px rgba(0, 0, 0, 0.7); 
box-shadow:0 15px 10px rgba(0, 0, 0, 0.7); 
-webkit-transform:rotate(70deg); 
-moz-transform:rotate(70deg); 
-o-transform:rotate(70deg); 
transform:rotate(70deg); 
} 

.top:after{ 
    /**One of the pseudo-elements then needs to be positioned on the other side of the element and rotated in the opposite direction. This is easily done by overriding only the properties that need to differ **/ 
right:0; 
left:auto; 
-webkit-transform:rotate(-70deg); 
-moz-transform:rotate(-70deg); 
-o-transform:rotate(-70deg); 
transform:rotate(-70deg); 
} 

.bottom:before, 
.bottom:after { 
    /** Generate pseudo-elements ('before' and 'after') and push them behind the container box. Position pseudo-elements ('before', and 'after') and give them dimensions **/ 
content:""; 
position:absolute; 
z-index:-2; 
top:90px; 
left:0; 
width:10%; 
max-width:150px; 
-webkit-box-shadow:0 15px 10px rgba(0, 0, 0, 0.7); 
-moz-box-shadow:0 15px 10px rgba(0, 0, 0, 0.7); 
box-shadow:0 15px 10px rgba(0, 0, 0, 0.7); 
-webkit-transform:rotate(99deg); 
-moz-transform:rotate(99deg); 
-o-transform:rotate(99deg); 
transform:rotate(99deg); 
} 

.bottom:after{ 
    /**One of the pseudo-elements then needs to be positioned on the other side of the element and rotated in the opposite direction. This is easily done by overriding only the properties that need to differ **/ 
right:0; 
left:auto; 
-webkit-transform:rotate(-99deg); 
-moz-transform:rotate(-99deg); 
-o-transform:rotate(-99deg); 
transform:rotate(-99deg); 
} 
+4

पर इस [कड़ी] एक नजर डालें (http://www.sitepoint.com/pure-css3-paper-curl/) यह एक नीचे कर्ल देखो कहते हैं, लेकिन यह आपको यह पता लगाने की है कि यह कैसे काम कर पाने के मदद कर सकता है बाएं और दाएं। –

+0

धन्यवाद, मैं एक jsfiddle और सीएसएस मैं अब तक है कि के साथ सवाल अपडेट किया गया। मुझे लगता है कि यह करीब है लेकिन अभी भी कुछ समस्याएं हैं। – Mdd

उत्तर

6

आपको लगता है कि प्राप्त करने के लिए पहले और बाद में सीएसएस गुणों का उपयोग कर सकते हैं। जांच यह पता: http://nicolasgallagher.com/css-drop-shadows-without-images/demo/

एक और तरीका है:

HTML:

<div id="box"> 
<h1>css-3-box-shadow</h1> 
<p>some text</p> 
</div> 

सीएसएस:

#box:after { 
    left: auto; 
    right: 10px; 
    transform: rotate(3deg); 
} 
#box:before, #box:after { 
    background: none repeat scroll 0 0 rgba(0, 0, 0, 0.7); 
    bottom: 15px; 
    box-shadow: 0 15px 10px rgba(0, 0, 0, 0.7); 
    content: ""; 
    left: 10px; 
    max-width: 300px; 
    position: absolute; 
    top: 80%; 
    transform: rotate(-3deg); 
    width: 50%; 
    z-index: -1; 
} 
#box:before, #box:after { 
    background: none repeat scroll 0 0 rgba(0, 0, 0, 0.7); 
    bottom: 15px; 
    box-shadow: 0 15px 10px rgba(0, 0, 0, 0.7); 
    content: ""; 
    left: 10px; 
    max-width: 300px; 
    position: absolute; 
    top: 80%; 
    transform: rotate(-3deg); 
    width: 50%; 
    z-index: -1; 
} 
#box { 
    background: none repeat scroll 0 0 #DDDDDD; 
    border-radius: 4px 4px 4px 4px; 
    color: rgba(0, 0, 0, 0.8); 
    line-height: 1.5; 
    margin: 60px auto; 
    padding: 2em 1.5em; 
    position: relative; 
    text-shadow: 0 1px 0 #FFFFFF; 
    width: 60%; 
} 

रेफरी: http://www.red-team-design.com/wp-content/uploads/2011/04/css3-box-shadow.html

आशा है कि मदद करता है।

+0

युक्तियों के लिए धन्यवाद! मैंने एक jsfiddle और सीएसएस के साथ सवाल को अद्यतन किया है जो अब तक है। यहां फिर से पहेली है: http://jsfiddle.net/kXuQY/ मेरे "शीर्ष" वर्ग के लिए सीएसएस ओवरराइड किया गया है या कुछ ऐसा लागू नहीं कर रहा है। – Mdd

+1

@Mdd - आप क्या कर सकते हैं, 3 अलग डीआईवी बनाएं और फिर ऊपर और नीचे div (पहली div पर शीर्ष छाया और तीसरे div पर नीचे छाया) पर छाया (उपरोक्त कोड का उपयोग करके) लागू करें। सामग्री के लिए मध्य के रूप में छोड़ दें। और आखिरकार, पूरी चीज को एक एकीकृत बॉक्स की तरह दिखने के लिए सभी डीआईवी को स्थिति दें। – Learner

+0

धन्यवाद! मैंने पहेली को अपडेट किया और मुझे पता है कि अब क्या करना है। एक बार फिर धन्यवाद! http://jsfiddle.net/kLhP8/ – Mdd

संबंधित मुद्दे