背景图片随div的大小而改变其大小,该怎么解决

WBOY
Release: 2016-06-13 11:57:16
Original
1218 people have browsed it

背景图片随div的大小而改变其大小
背景图片随div的大小而改变其大小,我的div是可以人为改变的
------解决方案--------------------

<br /><style type="text/css"><br />.dd{<br />	background-image:url('http://www.csdn.net/css/logo.png');<br />	background-size:100% 100%;<br />	width:480px;<br />	height:180px;<br />	border:1px solid #FF0000;<br />}<br /></style><br /><br /><div class="dd"></div><br />
Copy after login

------解决方案--------------------
这个是CSS3,需要IE9及以上才支持。
------解决方案--------------------
用jQuery 获取宽度 在给div层的width属性赋值
------解决方案--------------------
兼容IE了。
<br /><style type="text/css"><br />.dd{<br />    background-image:url('http://www.csdn.net/css/logo.png');<br />    background-size:100% 100%;<br />    width:480px;<br />    height:180px;<br />    border:1px solid #FF0000;<br />	filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(<br />    src='http://www.csdn.net/css/logo.png',<br />    sizingMethod='scale');<br />}<br /></style><br /> <br /><div class="dd"></div><br />
Copy after login

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template