0

我正在尝试围绕广告处理这种形状,但仍然允许其中的正常文本流动。你可以看到它是一个引用,我一直在为曲线制作不同的 id 和 class。所以它实际上是 3 个元素的边界重叠,但我觉得它所做的工作比它需要的要多。

http://jsfiddle.net/dUKQe/

4

1 回答 1

1

这还不是 100% 完美(浏览器之间似乎有一些细微的像素差异需要敲定——我已经花了太长时间了),但总的来说,这非常接近您通过明智地使用伪元素。

请参阅示例小提琴

HTML

<div id="text3" class="text">
    <h4>Bruce Lee</h4>
        <p><q>Be like water making its way through cracks. Do not be assertive, but adjust to the object, and you shall find a way around or through it. If nothing within you stays rigid, outward things will disclose themselves. Empty your mind, be formless. Shapeless, like water. If you put water into a cup, it becomes the cup. You put water into a bottle and it becomes the bottle. You put it in a teapot, it becomes the teapot. Now, water can flow or it can crash. Be water, my friend.</q>
        </p>
</div> 

CSS

#text3 {
    position: absolute;
    top: 5px;
    left: 5px;
    z-index: 0;
}

.text h4 {
    width: 228px;
    color: #ffffff;
    background-color: #012E40;
    margin: 5px 5px 0 5px;
    padding: 10px 10px 0 10px;
    border: 3px solid #000000;
    border-bottom-width: 0;
    -moz-border-radius: 5px 5px 0px 0px;
    border-radius: 5px 5px 0px 0px;
    position: relative;
}

.text h4:before {
    content: '';
    position: absolute;
    width: 3px;
    height: 3px;
    right: -3px;
    bottom: 0;
    background-color: #012E40;
}

.text h4:after { /*upper light blue bkg */
    content: '';
    display: block;
    background-color: #1B4E59;
    border: 2px solid #000000;
    width: 210px;
    height: 3em;
    padding: 5px;
    margin-top: -9px;
    margin-left: 2px;
    margin-bottom: -2px;
    border-bottom-width: 0;
    -moz-border-radius: 5px 5px 0px 0px;
    border-radius: 5px 5px 0px 0px;
    position: relative;
    top: 10px;
    z-index: 1;
}

.text p {
    color: #ffffff;
    margin: -3em 5px 5px 5px;
    padding: 0 5px 5px;
    width: 448px;
    position: relative;
}

.text p:before { /* inset border corner */
    content: '';
    display: block;
    width: 200px;
    height: 3em;
    float: right;
    margin: -3px 0px 3px 15px;
    border: 3px solid #000000;
    border-top-width: 0;
    border-right-width: 0;
    -moz-border-radius: 0px 0px 0px 5px;
    border-radius: 0px 0px 0px 5px;    
}

.text p:after { /* lower dark blue bkg */
    content: '';
    display: block;
    position: absolute;
    top: 3em;
    right: 0;
    bottom: 0;
    left: 0;
    margin-top: -3px;
    background-color: #012E40;
    border: 3px solid #000000;
    -moz-border-radius: 0px 5px 5px 5px;
    border-radius: 0px 5px 5px 5px;
    z-index: -1;
}

.text p q {
    display: block;
    margin: 0 10px 10px;
    padding: 5px;
    position: relative;
    z-index: 2;
}

.text p q:before { /* 2nd inset border corner */
    content: '';
    display: block;
    height: .5em;
    width: 202px;
    position: absolute;
    top: 3em;
    right: 3px;
    border: 2px solid #000000;
    border-top-width: 0;
    border-right-width: 0;
    -moz-border-radius: 0px 0px 0px 5px;
    border-radius: 0px 0px 0px 5px;
    z-index: 3;    
}

.text p q:after { /* lower light blue bkg */
    content: '';
    display: block;
    position: absolute;
    top: 3.5em;
    right: 0;
    bottom: 0;
    left: 0;
    background-color: #1B4E59;
    border: 2px solid #000000;
    border-top-width: 0;
    -moz-border-radius: 0px 5px 5px 5px;
    border-radius: 0px 5px 5px 5px;
    z-index: -1;
}
于 2012-05-23T02:56:16.700 回答