急!!!html转换成css

html-css012

急!!!html转换成css,第1张

很简单,只要把html中各个标签的样式都提取出来,放到css中,在给各个元素引用就可以了。

1、在html中找到<head></head>标签,在其中增加<style type="text/css"></style>标记

2、找到html中的一个元素比如

<div style="background:greenalign:centerwidth:20%font-size:14px">xxx</div>这种,将其中的style=""双引号之间的内容复制,粘贴到1中创建的标记内。在用一个选择器包裹住,最后在元素上指定class="选择器"就可以了

3、例子 如下两个div,第一个在style中设置样式,第二个通过css引用样式,最终效果过一样

<html>

    <head>

        <style type="text/css">

            .divcss{

                background:green

                align:center

                width:20%

            }

        </style>

    </head>

    <body>

        <div style="background:greenalign:centerwidth:20%">xxx</div>

        <div class="divcss">xxx</div>

    </body>

</html>

css中设置字体 一般用 font-size 设置字体大小 font-weight :bold 设置字体加粗。如果你要设置字体样式 font-style 里面有各种字体 但是有些字体有兼容性问题 用的最多的是 微软雅黑(microsoft yahei)市面上的浏览器都能显示。