css 带有CSS 3D变换的倾斜标签

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了css 带有CSS 3D变换的倾斜标签相关的知识,希望对你有一定的参考价值。

{"view":"split","fontsize":"100","seethrough":"","prefixfree":"1","page":"html"}
// alert('Hello world!');
<!-- This HTML is invalid and just for demo purposes. Don't use multiple main elements! -->

<nav>
	<a href="#">Home</a>
	<a href="#" class="selected">Projects</a>
	<a href="#">About</a>
</nav>
<main>
	Content area
</main>

<nav class="left">
	<a href="#">Home</a>
	<a href="#" class="selected">Projects</a>
	<a href="#">About</a>
</nav>
<main>
	Content area
</main>

<nav class="right">
	<a href="#">Home</a>
	<a href="#" class="selected">Projects</a>
	<a href="#">About</a>
</nav>
<main>
	Content area
</main>
/**
 * Slanted tabs with CSS 3D transforms
 * See http://lea.verou.me/2013/10/slanted-tabs-with-css-3d-transforms/
 */

body { padding: 50px; }

nav {
	position: relative;
	z-index: 1;
	white-space: nowrap;
}

nav a {
	position: relative;
	display: inline-block;
	padding: 1.5em 1.5em 1em;
	color: inherit;
	text-decoration: none;
	margin: 0 -7px;
} 

nav a::before,
main {
	border: .1em solid #aaa;
}

nav a::before {
	content: ''; /* To generate the box */
	position: absolute;
	top: 0; right: 0; bottom: .5em; left: 0;
	z-index: -1;
	border-bottom: none;
	border-radius: 10px 10px 0 0;
	background: #ddd;
	box-shadow: 0 2px hsla(0,0%,100%,.5) inset;
	transform: perspective(5px) rotateX(2deg);
	transform-origin: bottom;
}

nav.left a {
	padding: 1.5em 2em 1em 1em;
}

nav.left a::before {
	transform-origin: bottom left;
}

nav.right a {
	padding: 1.5em 1em 1em 2em;
}

nav.right a::before {
	transform-origin: bottom right;
}

nav a.selected {
	z-index: 2;
}

nav a.selected::before {
	margin-bottom: -1px;
	border-top-width: 1px;
}

nav a.selected::before,
main {
	background: #eee;
}

main {
	display: block;
	margin: -8px 0 30px -15px;
	padding: 1em;
	border-radius: 3px;
}

以上是关于css 带有CSS 3D变换的倾斜标签的主要内容,如果未能解决你的问题,请参考以下文章

css3绘制的图形会不会影响原来的div

CSS3 3D Transform

CSS3 使用 JavaScript 拖动转换 3d 变换

Kidney自得其乐版CSS教程Chapter6 Transform

纯CSS实现蜂窝六边形的个性相册

CSS:不会破坏 3D 变换的“溢出:隐藏”替代方案