使用CSS环绕横幅(Wraparound Banner with CSS)

编程入门 行业动态 更新时间:2024-10-27 22:26:47
使用CSS环绕横幅(Wraparound Banner with CSS)

我目前正在尝试使用此CSS在我正在处理的网站主题上设置环绕式横幅类型交易:

http://asgeirhoem.no/ex/css-wraparound-ribbon/

我几乎逐字复制了所提到的网站上显示的内容:

(CSS)

header { position: relative; margin: 0 -10px; text-align: center; padding: 10px; background-color: #bb0000; color: white; text-shadow: 2px 2px 0 black; } header:before, header:after { content: ''; border-top: 10px solid #660000; position: absolute; bottom: -10px; } header:before { border-left: 10px solid transparent; } header:after { border-right: 10px solid transparent; }

(HTML)

<body> <div class="page-container"> <header> <img src="logo1.png" /> </header> </div> </body>

但它没有按预期工作。 这是我在浏览器中查看页面时得到的内容:

正如您所看到的,“环绕式”部分存在,但定位不正确,我不确定为什么会这样。 任何帮助都会很棒。

I'm currently trying to use this CSS to set up a wraparound banner type deal on a website theme I'm working on:

http://asgeirhoem.no/ex/css-wraparound-ribbon/

I've pretty much copied verbatim what's shown on the mentioned site:

(CSS)

header { position: relative; margin: 0 -10px; text-align: center; padding: 10px; background-color: #bb0000; color: white; text-shadow: 2px 2px 0 black; } header:before, header:after { content: ''; border-top: 10px solid #660000; position: absolute; bottom: -10px; } header:before { border-left: 10px solid transparent; } header:after { border-right: 10px solid transparent; }

(HTML)

<body> <div class="page-container"> <header> <img src="logo1.png" /> </header> </div> </body>

But it's not working as expected. This is what I'm getting when I look at the page in a browser:

As you can see, the "wraparound" sections exist, but are not positioned correctly, and I'm not sure why that is. Any help would be fantastic.

最满意答案

你错过了right物业:

header:before { border-left: 10px solid transparent; left: 0; } header:after { border-right: 10px solid transparent; right: 0; }

的jsfiddle

You missed the left and right property:

header:before { border-left: 10px solid transparent; left: 0; } header:after { border-right: 10px solid transparent; right: 0; }

jsFiddle

更多推荐

本文发布于:2023-08-07 18:22:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1465489.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:横幅   CSS   Banner   Wraparound

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!