GVKun编程网logo

css_初阶(初始css)

16

对于css_初阶感兴趣的读者,本文将提供您所需要的所有信息,我们将详细讲解初始css,并且为您提供关于20、CSS_html/css_WEB-ITnose、6.5Ext.util.CSS更好地操作cs

对于css_初阶感兴趣的读者,本文将提供您所需要的所有信息,我们将详细讲解初始css,并且为您提供关于20、CSS_html/css_WEB-ITnose、6.5 Ext.util.CSS 更好地操作css_html/css_WEB-ITnose、css sprint 生成工具 bg2css_html/css_WEB-ITnose、css style与class之间的区别,cssclass_html/css_WEB-ITnose的宝贵知识。

本文目录一览:

css_初阶(初始css)

css_初阶(初始css)

s10.html

<!DOCTYPE html>
<html lang="en">
<head>
    <Meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<form>
    <fieldset>
        <legend>登陆</legend>
        <label for="username">用户名:</label>
        <input id="username" type="text" name="user" value="alex">
        <br>
        <label for="Password">密码:</label>
        <input id="Password"type="text" name="password">
        <br>
        <input type="reset" value="重置">
        <input type="submit" value="提交">

    </fieldset>
</form>
</body>
</html>

 

 

s11.html

<!DOCTYPE html>
<html lang="en">
<head>
    <Meta charset="UTF-8">
    <title>Title</title>
    <style>
        /*#i1{
            background-color:#095bcc;
             height: 58px;
        }<!--id
选择器-->
         #i2{
            background-color:#095bcc;
             height: 58px;
         }
         #i3{
            background-color:#095bcc;
             height: 58px;
         }
        .c1{
            background-color:#895ccc;
             height: 18px;
         }<!--class
选择器-->
         */
        /*div{*/
        /*background-color:black;*/
        /*color:white;*/
        /*}<!--div
标签选择器对所有的div标签都有效都会设置此样式-->*/
        /*<css
注释: /* */

        /*span div {*/
            /*background-color: blue;*/
            /*color: #FFFFFF;*/
        /*}*/

        /*<!--*/
        /*
层级选择器用空格 span下的div标签有效-- >*/
        /*#i4,#i5,#i6{*/
            /*background-color: maroon;*/
            /*color: black;*/
        /*}<!--
组合选择器用逗号-->*/
        /*.i4,.i5,.i6{*/
            /*background-color: lawngreen;*/
            /*color: red;*/
        /*}<!--
组合选择器-->*/
       
.c2[n="jack"]{width: 100px;height: 100px }<!--属性选择器对选择到的标签再通过属性再进行一次筛选-->

    <!--最常用的是class选择器,其次是标签选择器 id选择器可以不用-->
    </style>
</head>
<body>
<div id="i1">a</div><!--id选择器-->
<div id="i2">b</div>

<div id="i3">c</div>

<div class="c1">ffff</div><!--syle属性背景颜色高度-->
<span class="c1">11<div>22</div></span><!--class选择器-->
<div class="c1">3</div>


<div id="i4">2233</div><!--id选择器-->
<div id="i5">dgdg</div>

<div id="i6">kkdlg</div>

<div class="i4">aaaaaaaaaaa</div>
<div class="i5"> bbbbbbbb</div>
<div class="i6">cccccccccc</div>

<input class="c2" n="jack" type="text">
<input class="c2"  type="password">

</body>
</html>

 

 

s12.html

<!DOCTYPE html>
<html lang="en">
<head>
    <Meta charset="UTF-8">
    <title>Title</title>
    <style>

        .c1{
            background-color: red;
            color: white;
        }
        .c2{
            font-size: 52px;
            color: black;
        }
    </style>
</head>
<body>
    <div class="c1 c2" style="color: pink" >gggggggggggggghhhhh</div>
    <div class="c1 c2" style="color: pink" >gggggggggggggghhhhh</div>
    <div class="c1 c2" style="color: pink" >gggggggggggggghhhhh</div>
    <div class="c1 c2" style="color: pink" >gggggggggggggghhhhh</div>

</body>
</html>

<!--标签上 style优先,然后是编写顺序,下面的优先-->

 

 

commons.css

.c1{
    background-color: red;
    color: white;
}
.c2{
    font-size: 52px;
    color: black;
}

<!--stylesheet css文件可被引用-->

 

s13.html

<!DOCTYPE html>
<html lang="en">
<head>
    <Meta charset="UTF-8">
    <title>tile</title>
    <link rel="stylesheet" href="commons.css"><!--引用css文件-->
</head>

<body>
<div class="c1 c2" style="color: pink">ajsddiia</div>>
</body>
</html>

 

 

s14.html

<!DOCTYPE html>
<html lang="en">
<head>
    <Meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
    <div style="border: 1px solid red;"><!--边框像素为1像素实体的红色-->
        <!--<divhttps://www.jb51.cc/tag/ott/" target="_blank">otted red ;">dotted
虚线-->
       
ddfd

    </div>
    <div style="height: 48px;width:80% ;
    color: red;
    border:1px solid red;
    font-size: 22px;
    text-align: center;
    line-height: 48px;
    font-weight:bold;
    ">ddddddddddd</div>
     <!--<width宽度可以设置占的屏幕显示百分比,但height不能设置占的百分比>-->
    <!--<height: 48px;width:80% div
高度和宽度>-->
    <!--<color: red;div
里字体颜色>-->
    <!--<border:1px solid red;div
加边框边框线粗1像素实体的边框线为红色>-->
    <!--<font-size: 22px;div
里字体大小>-->
    <!--text-align: center;
字体左右居中-->
    <!--<line-height: 48px;
等于height的像素高度 ;字体上下居中>-->
    <!--<font-weight:bold;
字体粗细>-->
</body>

</html>

 

 

s15.html

<!DOCTYPE html>
<html lang="en">
<head>
    <Meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
    <div style="width: 20%;background-color: red;float: left">1</div>
    <div style="width: 20%;background-color: black;float: left">2</div>

</body>
</html>
<!--float让标签飘起来块级标签也可以堆叠起来-->

 

 

s16.html

<!DOCTYPE html>
<html lang="en">
<head>
    <Meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
    <div style="background-color: red;display: inline">assf</div>
    <span style="background-color: red;display: block">ffff</span>
    <span style="background-color: blue;height: 50px;width: 70px">Alex</span>
    <a href="http://www.baidu.com" style="background-color: blue">Eric</a>
    <span style="display: inline-block;background-color: blue;height: 50px;width: 70px">CCC</span>

</body>
</html>

<!--display: inline 块级标签变行内-->
<!--display: block
行内标签变块级-->
<!--display: inline-block
具有行内标签的特性(有多少占多少),又可以设置高度宽度边距-->
<!--display:none
让标签消失-->
<!--
行内标签无法设置高度宽度边距-->
<!--
块级标签可以设置高度宽度边距-->

 

 

s17.html

<!DOCTYPE html>
<html lang="en">
<head>
    <Meta charset="UTF-8">
    <title>Title</title>
</head>
<body style="margin:0 ">
    <div style="border:1px solid red;height: 70px">
        <div style="background-color: green;height: 50px;margin-top:0px "></div>
    </div>

</body>
</html>

<!--<margin 外边距可以移到外面的边距>-->
<!--<bodymargin
使用例子去掉上面边距>-->

 

 

s18.html

<!DOCTYPE html>
<html lang="en">
<head>
    <Meta charset="UTF-8">
    <title>Title</title>
</head>
<body style="margin: 0 ;">
    <div style="border: 1px solid red;height: 70px;">
        <div style="background-color: green;height: 50px ;padding-top: 0px">asdfd</div>
    </div>
</body>
</html>

<!--padding内边距里面 div填充颜色-->
<!--<bodymargin
使用例子去掉上面边距>-->

 

 

s19_作业.html

<!DOCTYPE html>
<html lang="en">
<head>
    <Meta charset="UTF-8">
    <title>Title</title>
    <style>
        .pg-header {
            height: 38px;
            background-color: #dddddd;
            line-height: 38px;
        }
    </style>
</head>
<body style="margin: 0 auto;"><!--pg-header">
    <div style="width: 860px;margin: 0 auto"><!--divstylemargin:0 auto div会居中-->
       
<div style="float: left">收藏本站</div>

        <div style="float: right;">
            <a>登录</a>
            <a>注册</a>
        </div>
        <div style="clear: both"></div>
    </div>
</div>
<div>
    <div style="width: 860px;margin: 0 auto;">
        <div style="float: left;">
            log
        </div>
        <div style="float: right">
            <div style="height: 50px;width: 100px;background-color: #888888"></div>
        </div>
        <div style="clear:both"></div>
    </div>
</div>
<div style="background-color: red">
    <div style="width: 860px;margin: 0 auto;">
        asdad
    </div>
    <div style="clear: both"></div>
</div>
<div style="width: 300px;border: 1px solid red;"><!--div放的时候左边优先-->
    <!--<div
不设置高度,是为了让里面的div的高度占本div的高度百分之百>-->
   
<div style="width: 96px;height: 30px; border: 1px solid green;float: left;"></div>

    <div style="width: 96px;height: 30px; border: 1px solid green;float: left"></div>
    <div style="width: 96px;height: 30px; border: 1px solid green;float: left;"></div>
    <div style="width: 96px;height: 30px; border: 1px solid green;float: left;"></div>
    <div style="width: 96px;height: 30px; border: 1px solid green;float: left;"></div>
    <div style="width: 96px;height: 30px; border: 1px solid green;float: left;"></div>
    <div style="width: 96px;height: 30px; border: 1px solid green;float: left;"></div>
    <div style="width: 96px;height: 30px; border: 1px solid green;float: left;"></div>
    <div style="clear: both;"></div><!--<div相当于div里面的div浮起来了,div又把里面的div拉起来了,重新显示父类div表格>-->

</div>

</body>
</html>

<!--margin: 0 auto  0表示距离上下边距是0 auto表示当前div左右自动居中-->

20、CSS_html/css_WEB-ITnose

20、CSS_html/css_WEB-ITnose

css

层叠样式表(Cascading Style Sheets)。

用于定义显示HTML样式。

DIV和SPAN

div是块级元素。

立即学习“前端免费学习笔记(深入)”;

span是行级元素。

将一些页面中的内容包裹起来统一设置样式。

CSS语法

特征:值;

CSS嵌入页面的三种方式

行内样式

<div>这是红色的字。</div>
登录后复制

页内样式

<style type="text/css">  Selector{property:value;}</div>
登录后复制

引入外部样式表文件

<!-- 方式1 --><link rel="stylesheet" type="text/css" href="css/style.css" ><!-- 方式2 --><style type="text/css">@import url(css/style.css);</style>
登录后复制

优先级:就近原则,行内优先与页内,优先于外部文件。

CSS注释

/* 这里是注释部分 */
登录后复制

选择器

类选择器

  .类名 { 样式属性:值; }

<style>    p.red{color:red} </style><!-- 使用时 --><p>类选择器</p>
登录后复制

ID选择器

  #id名 { 样式属性:值; }

<style>    #id{color:red}</style><!-- 使用时 --> <p id="id">ID选择器</p>
登录后复制

标签选择器

  标签名 { 样式属性:值; }

<style>    body{color:red}</style><body>选择器</body>
登录后复制

分组选择器

  属性1,属性2,属性3 { 样式属性:值; }

<style>    h1,h2,h3,h5,p{color:#000;}</style><h1>选择器</h1>
登录后复制

子代选择器

<style>  ul>li{list-style:none}</style><ul><li>1</li><li>2</li></ul>
登录后复制

后台选择器

<style>  ul a{list-style:none}</style><ul><li><a href=''''>123</a></li><li>2</li></ul>
登录后复制

通用选择器

<style>  *{color:#000;}</style><h1>选择器</h1>
登录后复制

伪类选择符

:link默认样式:visited点击过样式:active点击时样式
登录后复制

伪元素选择符

:first-letter首字母:first-line首行
登录后复制

选择器优先级:!important > #id >.class > selector

单位和值

继承:就是被包在内部的标签享有外部标签的样式,但border、margin、padding、background不会被继承。

继承斜体

显示为: 继承斜体

em标继承了p标签的红色

display属性:none(隐藏)、block(块显示)、inline(行显示)、list-item(列表显示)。

color属性:前景颜色 可以rgb(100%,100%,100%); 、rgb(255,255,255); 、十六进制值 #ffffff;、短十六进制 #fff;

绝对长度单位:in英寸、cm厘米、mm毫米、pt磅。

相对长度单位:em文字本身大小、ex 1ex=0.5em ex的一半、px像素。

百分比值:%百分号,150%相当于1.5em

背景

background-color:背景颜色,transparent 透明。background-image:url() 背景图片background-repeat:平铺 repeat-x 横向、repeat-y 纵向、 no-repeat 不平铺background-position:位置 top、bottom、left、right、centerbackground-attachment:背景固定 fixed固定 不随屏幕滚动background:[color | image | position | repeat | attachment] 简写
登录后复制

文本

text-indent:文本缩进,常用首段缩进2emtext-align:对齐方式 left(左)、right(右)、center(居中)、justify(两端)white-space:处理空白 normal(只显示一个空白)、pre(不忽略空白)、nowrap(不换行)line-height:行间距,处理文档行与行之间的距离vertical-align:纵向对齐 baseline(基线对齐)、sub(下标对齐)、super(上标对齐)、bottom(底部对齐)、text-bootom(文本底端)、top(顶端对齐)、middle(中间对齐)word-spacing: 文字间隔 <span>加 宽 的 文 字 </span><span>变 窄 的 文 字</span>letter-spacing: 字母间隔 <span>abcd</span> <span>abcd</span>text-transform: 文本转换 uppercase(全部转换大写)、lowercase(全部转换小写)、capitalize(第一个字母大写)text-decoration:文本修饰 none(无下划线)、underline(下划线)、overline(文本顶部划线)、line-through(删除线)、blink(文本闪烁)
登录后复制

字体

font-famliy:字体 "微软雅黑"font-weight:加粗 bold(粗)、ligter(100~900)font-size:大小 px、em、%font-style:样式 italic(倾斜)、oblique(斜体)font-variant:变形 normal(默认)、small-caps(小型大写字母)font:[ font-famliy | font-weight | font-style | font-size | font-variant | line-height]
登录后复制

列表

list-style-type:列表样式 disc(实心圆点)、circle(空心圆点)、square(放块)、none(无)

list-style-image:列表图像 使用图片作为符号

list-style-position:列表位置 inside、outside

list-style:[ type | image | position ]

框与边框

width:宽度 px、%、autoheight:高度 px、%、autopadding:外边距padding-top、padding-right、padding-bottom、padding-left 单侧边距margin:边界margin-top、margin-right、margin-bottom、padding-left 单侧边界这俩 简写 padding|margin [top|right|bottom|left] 依次 上、右、下、左p{margin:1px 2px} 相当于 p{margin:1px 2px 1px 2px}border:边框border-style:边框样式 none(无)、dashed(虚线)、solid(实线)、dotted、double、groove、ridge、inset、outsetborder-width:边框宽度border-color:边框颜色以上三个属性可以单侧设置,如:border-top-style:none,border-right-width:2px,border-left-color:red.border:[ width | style | color ] border:1px solid #fff;
登录后复制

浮动定位

float:浮动 left(左浮动)、right(右浮动)、nont(无)clear:清楚 left(清楚左浮动)、right(清楚右浮动)、both(清楚全部)、none(不清楚)使用浮动时,需要注意宽度,如果宽度不能在当前页面所包容,则会换行。使用完浮动后记得清除浮动,否则下面的元素也跟着浮动。position:定位模式 static(默认)、relative(相对)、absolute(绝对)、fixed(绝对)、inherit(继承)top,right,left,bottom 定位位置。使用定位时,可以在某个div指定定位容器 relative ,然后在这个容器中 所使用的定位是相对与这个容器的,而不是相对于浏览器。如bottom 1px 则在div的底部而不是浏览器底部。overflow:溢出处理 visible(显示默认)、hidden(隐藏)、scoll(滚动条) 当超过指定高度或宽度时的处理z-index:显示级别 数字越大越高,避免被遮盖,或者故意遮盖某块。
登录后复制

 

6.5 Ext.util.CSS 更好地操作css_html/css_WEB-ITnose

6.5 Ext.util.CSS 更好地操作css_html/css_WEB-ITnose

<div>        <divid="myPanel"></div>        <divid="myPanel1"></div></div>
登录后复制
.box { padding:50px 0 0 50px; }* { padding:0; margin:0; }.w_320 { width:320px; float:left; margin-right:15px;margin-bottom:15px; }.my-foo-trigger { border-radius:5px; }
登录后复制
Ext.onReady(function(){        //6.5 Ext.util.CSS 更好地操作css        //6.5.1 createStyleSheet(String cssText,String id) 自动创建一个样式表供html使用    //cssText : .myClass(color:blue;)  id : 将指定创建的css绑定到一个id        //6.5.2 getRule() 通过指定的css名称查询css规则        var myPanel = new Ext.Panel({        title : ''样式表的创建和获取'',        width : 320,        height : 210,        renderTo : ''myPanel'',        frame : true,        html : ''<div>我是内容部分</div>'',        buttons : [{                text : ''添加样式'',                handler : addSs            },{                text : ''移除样式'',                handler : reSs            }        ]    });    //创建    Ext.util.CSS.createStyleSheet(".myClass{color:blue}","the");    //获取样式规则    var cssObj = Ext.util.CSS.getRule(".myClass",true);    console.info("颜色:"+cssObj.style.color);        //6.5.3 swapStyleSheet() 动态改变页面的风格    var themes = [        {''theme'':''gray风格'',''css'':''theme-gray/resources/theme-gray-all.css''},        {''theme'':''classic风格'',''css'':''theme-classic/resources/theme-classic-all.css''},        {''theme'':''crisp风格'',''css'':''theme-crisp/resources/theme-crisp-all.css''},        {''theme'':''triton风格'',''css'':''theme-triton/resources/theme-triton-all.css''},        {''theme'':''neptune风格'',''css'':''theme-neptune/resources/theme-neptune-all.css''},        {''theme'':''aria风格'',''css'':''theme-aria/resources/theme-aria-all.css''}    ];    //创建主体数据模型    Ext.define(''Theme'',{        extend: ''Ext.data.Model'',        fields : [''theme'',''css'']    });    //创建主体数据源    var themeStore = Ext.create(''Ext.data.Store'',{        model : ''Theme'',        data : themes    });    var themeChange = Ext.create(''Ext.form.ComboBox'',{        id : ''themeChange'',        width : 180,        labelWidth : 60,        labelSeparator : '': '',        fieldLabel : ''样式选择'',        store : themeStore,//数据源        editable : false,        triggerAction : ''all'',//单击触发会显示全部数据        displayField : ''theme'',        valueField : ''css'',        queryMode : ''local'',//本地模式        value : ''theme-gray/resources/theme-gray-all.css'',//默认风格        listeners : {            ''collapse'' : function(){                Ext.util.CSS.swapStyleSheet(''theme'',''plugin/ext-6.0.0/build/classic/''+this.getValue());            }        }    });    //定义panel    Ext.create(''Ext.form.FormPanel'',{        title : ''Ext.form.ComboBox本地数据源示例'',        renderTo : ''myPanel1'',        bodyStyle : "padding:5px;",        frame : true,        height : 210,        width : 320,        defaults : {            labelSeparator : '': '',            labelWidth : 70,            width : 200,            labelAlign : ''left''        },        items : themeChange    });        //6.5.4    removeStyleSheet() 移除样式规则    //创建样式规则    function addSs(){        Ext.util.CSS.createStyleSheet(".myClass{color:blue}","the");    }    //移除样式规则    function reSs(){        Ext.util.CSS.removeStyleSheet("the");    }    });
登录后复制


css sprint 生成工具 bg2css_html/css_WEB-ITnose

css sprint 生成工具 bg2css_html/css_WEB-ITnose

今天需要改个css sprint,之前使用过一个工具蛮好使,但是就是想不起叫什么名字,网上搜了很久,才再次找到,原来是bg2css,今天记录下,以备以后不时之需。

下载地址:http://www.cssforest.org/blog/index.php?s=download

软件安装:该软件依赖Adobe Air,安装之前先要安装下Adobe Air,然后再安装该软件。

操作技巧:虽然已多次使用该软件,但由于时间间隔较长,每次用的时候,都不知道如何在图片上面加个选区层,然后拖动选区,选择要选取的图标。其实很简单,只要在图片上面双击下就可以了,双击图片,双击图片,双击图片,重要的事情说三遍!

软件界面:

立即学习“前端免费学习笔记(深入)”;

css style与class之间的区别,cssclass_html/css_WEB-ITnose

css style与class之间的区别,cssclass_html/css_WEB-ITnose

问题描述:

   网页点击【导出】按钮后,将页面table内容另存成excel文件,却发现无法保存表格样式

 

分析过程:

   1.table表格用class,而不是style。导出时并没有导出class定义,若换成style,将颜色样式直接写在style中,就会导出样式。

立即学习“前端免费学习笔记(深入)”;

    style是样式,在HTML中用这个来标明属性样式,是css中的内容,而class是类,申明和定义里面的内容,导出页面时并不会导出定义即class所定义的样式。

  2.将类定义放到table中也可以导出样式

解决方法-:

   将换成

补充:

 $(''#export'').click(function () {
  saveAsExcel($(''h3'').text(), $(''#table'').html().replace(/( )+/gi,''''));
 });

其中excel只识别table,使用saveAsExcel方法自动另存时,class定义保存不了;如果手工拷贝粘贴到excel时,class定义就能保存了。

主要还是手工与自动拷贝粘贴问题

网页设计

解决方法二:

  将在

中定义的类移动到
之间即可。类定义样式的位置问题

今天关于css_初阶初始css的介绍到此结束,谢谢您的阅读,有关20、CSS_html/css_WEB-ITnose、6.5 Ext.util.CSS 更好地操作css_html/css_WEB-ITnose、css sprint 生成工具 bg2css_html/css_WEB-ITnose、css style与class之间的区别,cssclass_html/css_WEB-ITnose等更多相关知识的信息可以在本站进行查询。

本文标签: