zoukankan      html  css  js  c++  java
  • 18 12 25 css 基本语法以及页面使用

    css的定义方法是:

    选择器 { 属性:值; 属性:值; 属性:值;}

    选择器是将样式和页面元素关联起来的名称,属性是希望设置的样式属性每个属性有一个或多个值

    css页面引入方法:

    1、外联式:通过link标签,链接到外部样式表到页面中。

    <link rel="stylesheet" type="text/css" href="css/main.css">
    

    2、嵌入式:通过style标签,在网页上创建嵌入的样式表。

    <style type="text/css">
        div{ 100px; height:100px; color:red }
        ......
    </style>
    

    3、内联式:通过标签的style属性,在标签上直接写样式。

    <div style="100px; height:100px; color:red ">......</div>


    css文本设置

    常用的应用文本的css样式:

    • color 设置文字的颜色,如: color:red;

    • font-size 设置文字的大小,如:font-size:12px;

    • font-family 设置文字的字体,如:font-family:'微软雅黑';

    • font-style 设置字体是否倾斜,如:font-style:'normal'; 设置不倾斜,font-style:'italic';设置文字倾斜

    • font-weight 设置文字是否加粗,如:font-weight:bold; 设置加粗 font-weight:normal 设置不加粗

    • line-height 设置文字的行高,设置行高相当于在每行文字的上下同时加间距, 如:line-height:24px;

      • font 同时设置文字的几个属性,写的顺序有兼容问题,建议按照如下顺序写: font:是否加粗 字号/行高 字体;如: font:normal 12px/36px '微软雅黑';

      • text-decoration 设置文字的下划线,如:text-decoration:none; 将文字下划线去掉

      • text-indent 设置文字首行缩进,如:text-indent:24px; 设置文字首行缩进24p

    text-align 设置文字水平对齐方式,如text-align:center 设置文字水平居中

  • 相关阅读:
    MVC,MVP,MVVM的区别
    jQuery Mobile 实现苹果滑动删除闹钟功能的几点总结
    AngularJS执行流程详解
    基于angularJS的表单验证练习
    jQuery 中 attr() 和 prop() 方法的区别
    天猫消息盒子的CSS实现
    jQuery事件之传递参数
    浅谈js中的垃圾两种回收机制
    js中的DOM操作汇总
    log4net
  • 原文地址:https://www.cnblogs.com/fromlantianwei/p/10172543.html
Copyright © 2011-2022 走看看