dw如何为图片设置css样式

html-css06

dw如何为图片设置css样式,第1张

dw里怎样设置图片的css样式

1、首先在文件内插入一张图片,点击插入\图像,选择一张图片即可。

2、选中图像,点击css样式窗口的+号,新建一个CSS(相关课程推荐:css视频教程) 样式,打开对话框。选择标签元素,下面就自动变为img,就是说为图像编辑规则。

3、比如要为图片编辑边框,就在弹出的对话框中选择边框,有三个属性可以更改,一个是类型,大小和颜色。可以根据需要选择。

4、在右侧的css面板上就多了个边框属性,代码中多了个图像的css样式代码。图像就自动按照样式进行更改了。

5、如果要对该图像再进行修改,可以点击css样式窗口下的铅笔,在弹出的对话框中修改即可。

写个简单的例子给你吧

htlm如下:

<h4>图片水平居中</h4>

<div class="demo1">

<img src="你的图片" alt="">

</div>

<h4>图片垂直居中</h4>

<div class="demo2">

<div class="imgbox">

<img src="你的图片" alt="">

</div>

</div>

<h4>图片水平垂直居中</h4>

<div class="demo3">

<div class="imgbox">

<img src="你的图片" alt="">

</div>

</div>

css如下:

<style type="text/css">

.demo1{width: 200pxheight: 200pxborder: 1px solid #cccdisplay: inline-blocktext-align: center}

.demo1 img{width: 100pxheight: auto}

.demo2{width: 200pxheight: 200pxborder: 1px solid #cccdisplay: table}

.demo2 .imgbox{display: table-cellvertical-align: middle}

.demo2 .imgbox img{width: 100pxheight: auto}

.demo3{width: 200pxheight: 200pxborder: 1px solid #cccdisplay: table}

.demo3 .imgbox{display: table-cellvertical-align: middletext-align: center}

.demo3 .imgbox img{width: 100pxheight: auto}

</style>

1.打开dw软件并创建一个新文档。

2.在dw中,编写以下css样式:<style>.mengsb {width:648pxmargin:0px auto}.jixing1 a {position:relativewidth:320pxmargin:0 0px 0 0float:leftheight:232px}。

3.然后将以下图像添加到正文中,代码为:<body><div class =“mengsb”>。

4.查看实时视图中的最终效果。

5,另外,你可以改变一些参数来实现不同的效果,可以改变背景颜色。

6.最后,看看改变颜色的效果。