请教高手图中六角图片如何切片和写css代码啊~~~六角图片要能能点击和超链接

html-css020

请教高手图中六角图片如何切片和写css代码啊~~~六角图片要能能点击和超链接,第1张

PNG虽然是好办法,但是因为做Z-INDEX,也不是很方便的,最好的办法就是CSS3来实现。

那个说不能实现那个,估计连CSS都不了解,即使用CSS2都可以实现,只是非常麻烦而且。

这是CSS3新属性实现的方法。

下面是CSS3实现几种多边形的代码,你复制,浏览一下就知道了。。。

附件是,CSS3实现的更多形状。

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html charset=utf-8" />

<title>css graph</title>

<style type="text/css" media="screen">

/*五边形*/

#pentagon {

    position: relative

    width: 54px

    border-width: 50px 18px 0

    border-style: solid

    border-color: #f66 transparent

    margin: 50px 0px 20px 20px

}

#pentagon:before {

    content: ""

    position: absolute

    height: 0

    width: 0

    top: -85px

    left: -18px

    border-width: 0 45px 35px

    border-style: solid

    border-color: transparent transparent #f66

}

/*六边形*/

#hexagon {

width: 100px

height: 55px

background: #f66

position: relative

        margin: 50px 0px 50px 20px

}

#hexagon:before {

content: ""

position: absolute

top: -25px 

left: 0

width: 0

height: 0

border-left: 50px solid transparent

border-right: 50px solid transparent

border-bottom: 25px solid #f66

}

#hexagon:after {

content: ""

position: absolute

bottom: -25px 

left: 0

width: 0

height: 0

border-left: 50px solid transparent

border-right: 50px solid transparent

border-top: 25px solid #f66

}

/*八边形*/

#octagon {

width: 100px

height: 100px

background: #f66

position: relative

}

#octagon:before {

content: ""

position: absolute

top: 0

left: 0    

border-bottom: 29px solid #f66

border-left: 29px solid #fff

border-right: 29px solid #fff

width: 42px

height: 0

}

#octagon:after {

content: ""

position: absolute

bottom: 0

left: 0    

border-top: 29px solid #f66

border-left: 29px solid #fff

border-right: 29px solid #fff

width: 42px

height: 0

}

</style>

</head>

<body>

<span style="font-size:27px">CSS graph</span>

<div id="pentagon"></div>五边形<br />

<div id="hexagon"></div>六边形<br />

<div id="octagon"></div>八边形<br />

</body>

</html>

css不同的多边形的层写法是不同的。

一、梯形代码:

.triangle {

    border-bottom: 100px solid #F36823

    border-left: 50px solid transparent

    border-right: 50px solid transparent

    height: 0

    width: 100px

}

二、六角星代码:

.triangle{

    width: 0

    height: 0

    border-left: 50px solid transparent

    border-right: 50px solid transparent

    border-bottom: 100px solid red

    position: relative

}

 

.triangle:after {

    width: 0

    height: 0

    border-left: 50px solid transparent

    border-right: 50px solid transparent

    border-top: 100px solid red

    position: absolute

    content: ""

    top: 30px

    left: -50px

}

3、五角星代码:

.triangle{

    margin: 50px 0

    position: relative

    display: block

    color: #F36823

    width: 0px

    height: 0px

    border-right:  100px solid transparent

    border-bottom: 70px  solid #F36823

    border-left:   100px solid transparent

    -moz-transform:    rotate(35deg)

    -webkit-transform: rotate(35deg)

    -ms-transform:     rotate(35deg)

    -o-transform:      rotate(35deg)

}

 

.triangle:before {

    border-bottom: 80px solid #F36823

    border-left: 30px solid transparent

    border-right: 30px solid transparent

    position: absolute

    height: 0

    width: 0

    top: -45px

    left: -65px

    display: block

    content: ''

    -webkit-transform: rotate(-35deg)

    -moz-transform:    rotate(-35deg)

    -ms-transform:     rotate(-35deg)

    -o-transform:      rotate(-35deg)

}

 

.triangle:after {

    position: absolute

    display: block

    color: #F36823

    top: 3px

    left: -105px

    width: 0px

    height: 0px

    border-right: 100px solid transparent

    border-bottom: 70px solid #F36823

    border-left: 100px solid transparent

    -webkit-transform: rotate(-70deg)

    -moz-transform:    rotate(-70deg)

    -ms-transform:     rotate(-70deg)

    -o-transform:      rotate(-70deg)

    content: ''

}

4、六边形代码:

.triangle{

    width: 100px

    height: 55px

    background: #F36823

    position: relative

}

 

.triangle:before {

    content: ""

    position: absolute

    top: -25px

    left: 0

    width: 0

    height: 0

    border-left: 50px solid transparent

    border-right: 50px solid transparent

    border-bottom: 25px solid #F36823

}

 

.triangle:after {

    content: ""

    position: absolute

    bottom: -25px

    left: 0

    width: 0

    height: 0

    border-left: 50px solid transparent

    border-right: 50px solid transparent

    border-top: 25px solid #F36823

}