zoukankan      html  css  js  c++  java
  • 22 , CSS 构造颜色、背景与图像

    1. 设定颜色

    2. 背景使用

    3. 图像使用

    1.设定颜色

    红色的几种合法定义;

    #f00;

    #ff0000;

    Red;

    Rgb(255,0,0);

    Rgb(100%,0%,0%);

    2.十六进制三元组

    第一个字节:红色的值;

    第二个字节:绿色的值;

    第三个字节:蓝色的值;

    简化写法:#cccccc 可写成 #ccc, #ff6633 可以写成 #f63

    3.使用 17 种具名颜色

    黑色(black) 000000

    藏蓝色(navy) 000080

    绿色(green) 008000

    海蓝色(teal) 008080

    银色(silver) 0c0c0c

    蓝色(blue) 0000ff

    酸橙色(lime) 00ff00

    浅绿色(aqua) 00ffff

    绛紫色(maroon) 800000

    紫色(purple) 800080

    橄榄绿(olive) 808000

    灰色(gray) 808080

    红色(red) ff0000

    紫红色(fuchsia) ff00ff

    黄色(yellow) ffff00

    橙色(orange) ffa500

    白色(white) ffffff

    4.使用 span 更好的控制文本中局部区域的文本

    <span>文本内容</span>

    5.使用 display 属性提供区块转换

    inline,block,none

    6.背景图象渐变的制作

    Body {

    Background: #ccc url(bg.gif) rpeat-x;

    }

    7.给一个区块加上一个背景

    #branding {

    Width: 700px;

    Height: 200px;

    Background: url(branding.gif) no-repeat;

    }

    8.给标题加上一个小图标

    H1 {

    Padding-left: 20px;

    Background: url (bullet.gif) no-repeat left center;

    }

    如果希望使用百分比而不使用关键字,0 50%这样就实现了垂直居中

    9.圆顶角

    <div class=box>

    <h2>Headline</h2>

    <p>Content</p>

    </div>

    .box {

    Width: 418px;

    Background: #ccc url(bottom.gif) no-repeat left bottom;

    }

    .box h2 {

    Background:url(top.gif) no-repeat left top;

    }

    如果不希望碰到边界,加上填充.

    .box h2 {

    Padding:10px 20px 0 20px;

    }

    .box p {

    Padding:0 20px 10px 20px;

    }

    10.简单的 CSS 阴影效果

    <div class="img-wrapper">

    <img src="images/dunstan.jpg" width="300" height="300" alt="Dunstan Orchard" />

    </div>

    .img-wrapper {

    background: url(images/shadow.gif) no-repeat bottom right;

    clear: right;

    float: left;

    position: relative;

    margin: 10px 0 0 10px;

    }

    .img-wrapper img {

    display: block; /*这个属性到列表再进行解释*/

    margin: -5px5px 5px -5px;

    position: relative;

    }

    5使用 display 属性提供区块转换 

    <!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>使用 display 属性提供区块转换</title>
    <style type="text/css">
    	div {
    		 200px;
    		height: 200px;
    		background: red;
    		display: inline;
    	}
    	
    	span{
    		 200px;
    		height: 200px;
    		background: red;
    		display:block;
    	}
    	/*
    	block转换成区块
    	inline转换成内联
    	none不占位的隐藏
    	*/
    	
    </style>
    </head>
    
    <body>
    <div>使用 display 属性提供区块转换:区块转内联</div><br/><br/>
    <span>内联转区块,使用 span 更好的控制文本中局部区域的文本</span>
    </body>
    </html>
    

      6背景图象渐变的制作

    <!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>使用 display 属性提供区块转换</title>
    <style type="text/css">
    	Body {
    Background: #ccc url(images/1.png) rpeat-x;
    }
    	
    	
    	
    </style>
    </head>
    
    <body>
    <div>背景图象渐变的制作</div> 
    <br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>
    <br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>
    <br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>
    <br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>
    <br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>
    <br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>
    <br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>
    <br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>
    <br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>
    <br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>
    <br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>
    <br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>
    <br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>
    <br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>
    <br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>
    </body>
    </html>
    

      7给一个区块加上一个背景

    <!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>给一个区块加上一个背景</title>
    <style type="text/css">
    	
    	div{
    		 200px;
    		height: 200px;
    		background:red url(images/bg.jpg) no-repeat right bottom;
    	}
    	
    	
    </style>
    </head>
    
    <body>
    <div>给一个区块加上一个背景</div>
    </body>
    </html>
    

      8给标题加上一个小图标

    <!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>给一个区块加上一个背景</title>
    <style type="text/css">
    	
    	H1 {
    Padding-left: 20px;
    Background:url(2.jpg) no-repeat left center;
    }
    	
    	
    </style>
    </head>
    
    <body>
    <h1>给标题加上一个小图标</h1>
    </body>
    </html>
    

      9圆顶角

    <!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>给一个区块加上一个背景</title>
    <style type="text/css">
    	
    	div{
    		320px;
    		height:180px;
    		background:blue url(images/2.png) no-repeat left bottom;
    }
    	h1{
    		background: url(images/3.png) no-repeat left top;
    	}
    	
    </style>
    </head>
    
    <body>
    <div>
    <h1>圆顶角圆顶角圆顶角</h1>
    <P>圆顶角圆顶角圆顶角圆顶角圆顶角圆顶角圆顶角圆顶角圆顶角圆顶角圆顶角圆顶角圆顶角圆顶角圆顶角</P>
    </div>
    </body>
    </html>
    

      10简单的 CSS 阴影效果

    <!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>给一个区块加上一个背景</title>
    <style type="text/css">
    	
    	body{
    		background: #fff;
    	}
    	div{
    		320px;
    		height:180px;
    		background:blue;
    }
    		
    </style>
    </head>
    
    <body>
    <div>
    <img src="images/pic7.jpg"/>还没有学好
    </div>
    </body>
    </html>
    

      

    柳志军:13418977808(手机微信),QQ:93684042
  • 相关阅读:
    leetcode 二进制求和 python
    leetcode 66.加一 python3
    django自定义simple_tag和filter
    deepin Gtk-WARNING **: 无法在模块路径中找到主题引擎:“adwaita”
    MySQL ERROR 1698 (28000): Access denied for user 'root'@'localhost'
    deepin 安装scrapy安装出错:fatal error: Python.h 的解决办法
    Bootstrap的$(...).modal is not a function错误
    linux 安装mysql5.6
    linux之主机名bogon问题详解
    linux开启代理转发功能
  • 原文地址:https://www.cnblogs.com/liu-zhijun/p/10630177.html
Copyright © 2011-2022 走看看