css - 伪类before/after中的图片大小是不是不能设置的?
问题描述
#center_box:before{content:url(http://localhost/quding/photos/u14.png);position: absolute;width:1000px;height:200px;z-index: 100;top: -110px; }
随我怎么调width,height都没变化.
问题解答
回答1:你可以把图片设为背景图片,通过bakckground-size来设置大小
#center_box:before{ content:’’; background-image:url(http://localhost/quding/photos/u14.png); background-size:1000px 200px; position: absolute; width:1000px; height:200px; z-index: 100; top: -110px;}回答2:
:before /:after伪元素默认是一个行内元素,所以这个元素设置width/height是无效的就像你对a元素设置width/height一样设置position: absolute;后这个元素的display属性计算为block值;但是设置的width/height针对的是:before/:after生成的匿名替换元素,而不是其中的content所以图片的大小是没有效果的
相关文章:
1. docker容器呢SSH为什么连不通呢?2. 关docker hub上有些镜像的tag被标记““This image has vulnerabilities””3. docker网络端口映射,没有方便点的操作方法么?4. nignx - docker内nginx 80端口被占用5. debian - docker依赖的aufs-tools源码哪里可以找到啊?6. 前端 - ng-view不能加载进模板7. android clickablespan获取选中内容8. angular.js - angular内容过长展开收起效果9. python - from ..xxxx import xxxx到底是什么意思呢?10. angular.js - ng-grid 和tabset一起用时,grid width默认特别小
