如图,左边的项目符号是图片做的,现在错位了。怎么设置图片的边距啊?
不用list-style-image 这个属性
用background: url(1.png) no-repeat 74px;
呵呵的确是用错了属性哦,用li背景 或者是 li a的背景来模拟list-type-image更好一些了,起码定位没有那么困难
嗯。以前没怎么用list-type-image,以为它有定位的功能呢。现在看来还是不行。
有没有可能让背景图片的文件名逐个累加:
例如有10个LI,背景图片分别从icon1.gif 到 icon10.gif,这些背景图片都是要在li前面显示。能不能只定义一个CSS实现出来?非得定义10个一个个的调用吗?
/*-----------------------------------.top10-----------------------------------*/ #top10 li { line-height:160%; padding-left:24px; border-bottom:1px #ccc dashed; width:150px; overflow:hidden; } #top10 a:hover { color:#C90; } #top10 .top1 { background:url(images/top_1.gif) no-repeat left center; } #top10 .top1 a { color:#06f; } #top10 .top1 a:hover { color:#f60; } #top10 .top2 { background:url(images/top_2.gif) no-repeat left center; } #top10 .top2 a { color:#06f; } #top10 .top2 a:hover { color:#f60; } #top10 .top3 { background:url(images/top_3.gif) no-repeat left center; } #top10 .top3 a { color:#0066FF; } #top10 .top3 a:hover { color:#f60; } #top10 .top4 { background:url(images/top_4.gif) no-repeat left center; } #top10 .top5 { background:url(images/top_5.gif) no-repeat left center; } #top10 .top6 { background:url(images/top_6.gif) no-repeat left center; } #top10 .top7 { background:url(images/top_7.gif) no-repeat left center; } #top10 .top8 { background:url(images/top_8.gif) no-repeat left center; } #top10 .top9 { background:url(images/top_9.gif) no-repeat left center; } #top10 .top10 { background:url(images/top_10.gif) no-repeat left center; }
非要不一个个定义,那就先把10张连成一竖串,做成一张图片---->
接下来有两张方法:
1.把图片作为ul的背景,间距+图片高度=li的line-height。坏处:你得保证li不折行。
2.用js判断出现的第几个li,分别赋予对应background-position:*px;里“*”的值。
--------------------
好处:图片只需去服务器上请求一次,这点对大站点来说,是非常重要的。
以上是 css:list-style-image中的图片背景如何设置?的详细内容。更多信息请关注PHP中文网其他相关文章!

@keyframesandCSSTransitionsdifferincomplexity:@keyframesallowsfordetailedanimationsequences,whileCSSTransitionshandlesimplestatechanges.UseCSSTransitionsforhovereffectslikebuttoncolorchanges,and@keyframesforintricateanimationslikerotatingspinners.

我知道,我知道:有大量的内容管理系统选项可用,而我进行了几个测试,但实际上没有一个是一个,y'知道吗?怪异的定价模型,艰难的自定义,有些甚至最终成为整个&

链接CSS文件到HTML可以通过在HTML的部分使用元素实现。1)使用标签链接本地CSS文件。2)多个CSS文件可通过添加多个标签实现。3)外部CSS文件使用绝对URL链接,如。4)确保正确使用文件路径和CSS文件加载顺序,优化性能可使用CSS预处理器合并文件。

选择Flexbox还是Grid取决于布局需求:1)Flexbox适用于一维布局,如导航栏;2)Grid适合二维布局,如杂志式布局。两者在项目中可结合使用,提升布局效果。

包含CSS文件的最佳方法是使用标签在HTML的部分引入外部CSS文件。1.使用标签引入外部CSS文件,如。2.对于小型调整,可以使用内联CSS,但应谨慎使用。3.大型项目可使用CSS预处理器如Sass或Less,通过@import导入其他CSS文件。4.为了性能,应合并CSS文件并使用CDN,同时使用工具如CSSNano进行压缩。

是的,youshouldlearnbothflexboxandgrid.1)flexboxisidealforone-demensional,flexiblelayoutslikenavigationmenus.2)gridexcelstcelsintwo-dimensional,confffferDesignssignssuchasmagagazineLayouts.3)blosebothenHancesSunHanceSlineHancesLayOutflexibilitibilitibilitibilitibilityAnderibilitibilityAndresponScormentilial anderingStruction

重构自己的代码看起来是什么样的?约翰·瑞亚(John Rhea)挑选了他写的一个旧的CSS动画,并介绍了优化它的思维过程。

CSSanimationsarenotinherentlyhardbutrequirepracticeandunderstandingofCSSpropertiesandtimingfunctions.1)Startwithsimpleanimationslikescalingabuttononhoverusingkeyframes.2)Useeasingfunctionslikecubic-bezierfornaturaleffects,suchasabounceanimation.3)For


热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

Video Face Swap
使用我们完全免费的人工智能换脸工具轻松在任何视频中换脸!

热门文章

热工具

SublimeText3 Mac版
神级代码编辑软件(SublimeText3)

禅工作室 13.0.1
功能强大的PHP集成开发环境

安全考试浏览器
Safe Exam Browser是一个安全的浏览器环境,用于安全地进行在线考试。该软件将任何计算机变成一个安全的工作站。它控制对任何实用工具的访问,并防止学生使用未经授权的资源。

SublimeText3 英文版
推荐:为Win版本,支持代码提示!

PhpStorm Mac 版本
最新(2018.2.1 )专业的PHP集成开发工具