Home >Web Front-end >HTML Tutorial >CSS(一)_html/css_WEB-ITnose

CSS(一)_html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-24 11:46:481085browse

Start the journey of learning css: first make one according to the style

1. Use DIV settings

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>第一个css样式</title><link type="text/css" rel="stylesheet" href="css/test1.css"  /></head><body><div></div><div></div><div></div><div></div></body></html>

css:

@charset "utf-8";/* CSS Document *//*定义DIV元素方形显示*/div {    width:200px;    height:200px;    border:solid 2px blue;    float:left;    margin:4px;}

2. Use class settings

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>第一个css样式</title><link type="text/css" rel="stylesheet" href="css/test1.css"  /></head><body><div></div><div></div><div class="green"></div><div class="red"></div></body></html>

css

@charset "utf-8";/* CSS Document *//*定义DIV元素方形显示*/div {    width:200px;    height:200px;    border:solid 2px blue;    float:left;    margin:4px;}/*定义.green类设置背景为绿色*/.green{    background-color:green;}/*定义.red类设置背景为红色*/.red{    background-color:red;}

Effect:

Statement:
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