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. 问题Unknown column ’’ in ’where clause’2. objective-c - ios 类似qq置顶的效果3. html - vue项目中用到了elementUI问题4. javascript - 在使用 vue.js element ui的时候 怎么样保留table翻页后check的值?5. mysql_replication - mysql读写分离时如果单台写库也无法满足性能怎么解决6. javascript - vue组件通过eventBus通信时,报错a.$on is not a function7. css3 - css怎么实现图片环绕的效果8. linux - ubuntu 命令行中文 显示菱形,期望通过引入字体解决而不是zhcon这种方式9. ionic 项目 ionic build android -release 打包时报错10. python - 如何用pandas处理分钟数据变成小时线?

网公网安备