Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/33.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
我可以把这个代码改成css吗_Css - Fatal编程技术网

我可以把这个代码改成css吗

我可以把这个代码改成css吗,css,Css,我想将这个imgsrc图像设置为css中的背景图像。请帮帮我。我想你说的是如何将背景图像设置为类“旋转”,而不是调用img src <div class="rotate"> <img src="image_url"/> </div> 旋转 { 背景:url(image.jpg)无重复中心; 宽度:100px; 高度:100px; } HTML方面应该是: <style type="text/css"> .rotate { backgrou

我想将这个imgsrc图像设置为css中的背景图像。请帮帮我。

我想你说的是如何将背景图像设置为类“旋转”,而不是调用img src

<div class="rotate"> <img src="image_url"/> </div>

旋转
{
背景:url(image.jpg)无重复中心;
宽度:100px;
高度:100px;
}
HTML方面应该是:

<style type="text/css"> 
.rotate
 {
 background:url(image.jpg) no-repeat center;     
 width:100px;
 height:100px;  
 }
</style>
<div class="rotate"> </div>

请注意,我想指出,添加背景的图像不起作用,因为没有定义大小,因此,如果我现在查看您的代码,您将得到一个空白图像,因为没有设置div大小。它将以0px×0px的宽度和高度渲染div。我在您必须设置的尺寸上添加了宽度和高度。设置宽度和高度将适用于像素和em。

哪种代码?哪个背景图像?请再澄清一点。。。
<div class="rotate"></div>
.rotate {   // define a class in css
    background:url(image.jpg) no-repeat center; // asuming you dont want it repeat and centered in the middle of your div.
    width: *amount of pixels*;
    height: *amount of pixels*;
}