45 度角 + Box Shadow - 只使用 CSS
我需要仅使用 CSS
重新创建以下设计:
您在图片是网站容器的顶部 - “链接”是主菜单的一部分。
就目前而言,我已经创建了容器,但我不确定如何在不使用图像的情况下在导航上进行倾斜。
郑重声明:我不想使用图像,因为倾斜上的框阴影与浏览器渲染的框阴影匹配的可能性很小,尤其是在使用多个浏览器时。
我正在思考具有白色背景和盒子阴影的定位和旋转 div 的思路,但我还无法构建它。
有什么想法吗?
I need to recreate the following design using only CSS
:
What you're seeing in the picture is the top of a website container - the "links" are part of the main menu.
As it stands, I've created the container but I'm not sure how to go about making the slant on the navigation without using an image.
For the record: I'd rather not use an image as the chances of the box shadow on the slant matching up with box shadow rendered by the browser are slim-to-none, especially when it comes to multiple browsers.
I was thinking along the lines of a positioned and rotated div with a white background and a box shadow, but I haven't been able to build it yet.
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
有一种东西叫做砂纸< /a> 可以帮助您转换元素,即使在 IE 中也是如此!
您只需将其插入您的网站即可。
您也可以使用 CSS3 转换,您在问题中提到过:“除了 CSS 之外什么都不用。”
为此,您可以使用:
感谢 Josh 和 Robert 提供的 Opera 等效项:
Internet Explorer 将在任何应用了过滤器的文本上放置 ClearType。但是您可以在主元素内添加空的额外元素,并对这个额外元素应用过滤器。这样ClearType就不会被破坏并且可以达到相同的结果。
There is something called Sandpaper that can help you to transform your elements, even in IE!
You can just plug it into your site and you're set.
Also you can use CSS3 transforms, which you asked about in your question: "Using nothing but CSS."
To do this you'd use:
And thanks to Josh and Robert for the Opera equivalent:
Internet Explorer will drop ClearType on any text that has a filter applied to it. But you can add empty extra element inside the main one and apply filter to this extra element. After this ClearType will be not ruined and the same result can be achieved.
对于旋转,您需要:
请记住,旋转是 CSS3 属性,因此您不会在所有浏览器中获得相同的行为。与其仅用图像进行倾斜,不如重新创建整个轮廓可能会更好。我会用以下方法来处理它:
您还可以使用外部库来尝试重新创建 CSS3 属性,但图像可能是最简单的方法,因为您知道它们将如何呈现。
For rotation, you're looking for:
Keep in mind, that the rotation is a CSS3 attribute, so you're not going to get the same behavior across all browsers. Rather than making just the slant with an image, it would probably be better to recreate the whole outline. I'd approach it with:
You can also use external libraries to attempt to recreate CSS3 attributes, but images may be the easiest way as you know how they'll render.
我认为您可以使用 http://nicolasgallagher.com/pure-css- 中的技术voice-bubbles/demo/
这是一个非常好的汇编,也是使用 CSS 的灵感。享受。
PS:它比 CSS3 转换更安全。
I think you can use the techniques from http://nicolasgallagher.com/pure-css-speech-bubbles/demo/
This is a really nice compilation and inspiration for using CSS. Enjoy.
PS: it is safer than CSS3 transforms.
旋转似乎没有必要。我会尝试使用 CSS 三角形效果。
我假设您的链接位于
ul
中,因此您的 css 可以选择ul:before
并将其设置为正确的形状。我不知道
box-shadow
会发生什么,但它可能值得一试,并且可能会更容易在 IE 中对齐,而无需求助于 JavaScript。Rotation seems unnecessary. I would try using a CSS triangle effect.
I'm going to assume your links are in a
ul
so your css could selectul:before
and make it into the correct shape.I don't know what will happen with the
box-shadow
but it might be worth a shot, and will probably be easier to align in IE without resorting to JavaScript.