gpt4 book ai didi

html - 使用 :before & :after 排列图像

转载 作者:可可西里 更新时间:2023-11-01 13:11:24 26 4
gpt4 key购买 nike

我正在尝试使用伪选择器 :before:after 用边框图像包围一个 div。但是,我想我错过了一些东西。 :after 图像不会附加到元素的右侧,无论我尝试什么,文本都已下降到图像下方,如此 JsFiddle example 所示.

CSS

.panel {
border:2px solid #634e32;
border-radius:4px;
margin-bottom: 30px;
background-color: #ecd8b5;
}
.panel-header{
margin: -5px -1px 10px 2px;
padding-left: 15px;
background:url('http://eaassets-a.akamaihd.net/lougame/cdn/409444/resource/webfrontend/ui/win_mainoverlay_t.png') repeat-x;
}
.panel-header:before,
.panel-header:after{
content:"";
width:9px;
height:36px;
overflow:hidden;
}
.panel-header:before {
content: url('http://eaassets-a.akamaihd.net/lougame/cdn/409444/resource/webfrontend/ui/win_mainoverlay_tl.png');
margin-left:-20px;
}
.panel-header:after {
content: url('http://eaassets-a.akamaihd.net/lougame/cdn/409444/resource/webfrontend/ui/win_mainoverlay_tr.png');
}

HTML

<div class="panel">
<div class="panel-header">Header Title Goes Here</div>
</div>

最佳答案

http://jsfiddle.net/53xxV/

.panel {
border:2px solid #634e32;
border-radius:4px;
margin-bottom: 30px;
background-color: #ecd8b5;
position: relative;
padding-top:40px
}
.panel-header{
position:absolute;
top:0;
left:0;
right:0;
padding-left: 15px;
background:url('http://eaassets-a.akamaihd.net/lougame/cdn/409444/resource/webfrontend/ui/win_mainoverlay_t.png') repeat-x;
height : 29px;
color: hotpink; /* :P */
padding-top: 10px;
}
.panel-header:before,
.panel-header:after{
content:"";
width:9px;
height:36px;
overflow:hidden;
}
.panel-header:before {
content: url('http://eaassets-a.akamaihd.net/lougame/cdn/409444/resource/webfrontend/ui/win_mainoverlay_tl.png');
position:absolute;
left:0;
top:0;
}
.panel-header:after {
content: url('http://eaassets-a.akamaihd.net/lougame/cdn/409444/resource/webfrontend/ui/win_mainoverlay_tr.png');
position:absolute;
right:0;
top:0;
}

关于html - 使用 :before & :after 排列图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20697711/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com