CSS3背景图像定位
我决定玩一些CSS3,在背景图像方面遇到了一些问题。我的背景图像(六边形和箭头)显示不正确。六边形没有显示在父元素中,我无法使箭头向右移动 我正在使用边框图像,以便可以水平调整元素的大小 有什么建议吗 这就是它应该看起来的样子-> 这是六边形-> 这是箭头-> 这是锚元素背景-> 这是列表项元素背景-> HTMLCSS3背景图像定位,css,Css,我决定玩一些CSS3,在背景图像方面遇到了一些问题。我的背景图像(六边形和箭头)显示不正确。六边形没有显示在父元素中,我无法使箭头向右移动 我正在使用边框图像,以便可以水平调整元素的大小 有什么建议吗 这就是它应该看起来的样子-> 这是六边形-> 这是箭头-> 这是锚元素背景-> 这是列表项元素背景-> HTML <nav> <ul> <li> <a href="">Examples<
<nav>
<ul>
<li>
<a href="">Examples</a>
</li>
</ul>
</nav>
<nav><ul><li><a href="">Hello World</a></li><li><a href="">Hello</a></li><li><a href="">Hello World Hello World</a></li></ul></nav>
我已经编辑了我的css。看看这个 CSS 如果需要可拉伸的li元素,则拉伸图像会很混乱。我建议你把图像分成三部分。1.左侧部分包括左箭头角度和六边形2.右侧部分包括小箭头和右角度部分3.1px x 1px瓷砖图像。 在阅读了关于这个问题的文章后,我想出了一个解决这个问题的办法。我使用阿比德夫的建议将图像分为三部分 此解决方案还允许我缩小每个列表项的宽度(例如,为锚元素提供除“自动”之外的值) CSS
nav {
font-family: sans-serif;
font-weight: 700;
font-size: 24px
}
li {
display: inline-block;
height: 107px;
border-width: 1px 32px 1px 32px;
-moz-border-image: url('http://markschamel.com/graphics/themes/misc/nav.li.background.png') 1 32 1 32 stretch stretch;
-webkit-border-image: url('http://markschamel.com/graphics/themes/misc/nav.li.background.png') 1 32 1 32 stretch stretch;
-o-border-image: url('http://markschamel.com/graphics/themes/misc/nav.li.background.png') 1 32 1 32 stretch stretch;
border-image: url('http://markschamel.com/graphics/themes/misc/nav.li.background.png') 1 32 1 32 stretch stretch;
}
a {
display: inline-block;
height: 45px;
border-width: 1px 14px 1px 14px;
-moz-border-image: url('http://markschamel.com/graphics/themes/misc/nav.a.background.png') 1 14 1 14 stretch stretch;
-webkit-border-image: url('http://markschamel.com/graphics/themes/misc/nav.a.background.png') 1 14 1 14 stretch stretch;
-o-border-image: url('http://markschamel.com/graphics/themes/misc/nav.a.background.png') 1 14 1 14 stretch stretch;
border-image: url('http://markschamel.com/graphics/themes/misc/nav.a.background.png') 1 14 1 14 stretch stretch;
text-decoration: none;
line-height: 45px;
padding: 0 10px;
margin: 31px 0 0 17px;
background: url('http://markschamel.com/graphics/themes/misc/nav.hex.background.png') no-repeat -50px center,
url('http://markschamel.com/graphics/themes/misc/nav.arrow.background.png') no-repeat right center;
color: #d92701;
}
nav {
font-family: sans-serif;
font-size: 24px;
font-weight: 700;
}
nav ul {
height: 107px;
}
nav li {
display: inline-block;
height: 107px;
position: relative;
}
nav a {
display: inline-block;
color: #d92701;
text-decoration: none;
line-height: 4.5;
overflow: hidden;
height: 107px; width: auto;
background: transparent url('nav.background.expand.middle.png') repeat-x left top;
position: relative;
top: 0;
white-space:nowrap;
}
nav li:before {
content: "";
float: left;
width: 64px;
height: 107px;
margin: 0;
background: transparent url('nav.background.expand.begin.png') no-repeat left top;
}
nav li:after {
content: "";
float: right;
width: 58px;
height: 107px;
margin: 0;
background: transparent url('nav.background.expand.end.png') no-repeat right top;
}
HTML
<nav>
<ul>
<li>
<a href="">Examples</a>
</li>
</ul>
</nav>
<nav><ul><li><a href="">Hello World</a></li><li><a href="">Hello</a></li><li><a href="">Hello World Hello World</a></li></ul></nav>
不幸的是,如果我更改文本(即更改为“超长导航项”),它不会拉伸