Hybird App之选择器详解(一)

作者: Dwyane_Coding | 来源:发表于2018-01-01 17:05 被阅读350次

学习混合app开发,要学会一些基础才能上手。本文主要介绍元素选择器、选择器分组、类选择器

元素选择器

最常见的选择器就是元素选择器,文档的元素就是最基本的选择器
例如:h1{} a{}
index.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>选择器</title>
    <link href="style.css" type="text/css" rel="stylesheet">
</head>
<body>
    <p>Hello Dwyane!</p>
</body>
</html>

style.css

p{
    color: green;
}
选择器分组
<body>
    <h1>标题1</h1>
    <h2>标题2</h2>
</body>

style.css

h1, h2{
    color: green;
}

结果:


image.png

另外还有个通配符*,通常在通配符设置marigin值、padding值

*{
    margin: 0px;
    padding: 0px;
}
类选择器

1、类选择器允许以一种独立于文档元素的方式来指定样式
例如:.class{}
index.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>选择器</title>
    <link href="style.css" type="text/css" rel="stylesheet">
</head>
<body>
    <div class="div">hello,Dwyane</div>
</body>
</html>

style.css

.div{
    color: blue;
}

结果:


image.png

2、结合元素选择器:例如:a.class{}
index.html

<body>
    <div class="div">hello,Dwyane</div>
    <a class="div">hello,Dwyane</a>
</body>

style.css

a.div{
    color: blue;
}

只指定a标签的div更改,所以未指定的div不会更改
结果:


image.png

3、多类选择器
index.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>选择器</title>
    <link href="style.css" type="text/css" rel="stylesheet">
</head>
<body>
    <p class="p1">this is my web page</p>
    <p class="p2">this is my web page</p>
    <p class="p3">this is my web page</p>
</body>
</html>

style.css

.p1{
    color: blue; //p1更改颜色
}
.p2{
    font-size: 30px; //p2更改字号
}
.p3{
    font-style: italic; //p3斜体
}

结果:


image.png

运用多类选择器,我们可以
index.html

<body>
    <p class="p1">this is my web page</p>
    <p class="p2">this is my web page</p>
    <p class="p1 p2">this is my web page</p> //p1 p2中间用空格隔开,这样继承了前两个class的特性
</body>

style.css

.p1{
    color: blue; //p1更改颜色
}
.p2{
    font-size: 30px; //p2更改字号
}
.p1.p2{
    font-style: italic; //p1 p2斜体
}

结果:


image.png

.p1.p2继承了p1和p2的特性,再加上自己的斜体

相关文章

  • Hybird App之选择器详解(二)

    Hybird App之选择器详解(一) 学习混合app开发,要学会一些基础才能上手。本文主要介绍ID选择器、属性选...

  • Hybird App之选择器详解(一)

    学习混合app开发,要学会一些基础才能上手。本文主要介绍元素选择器、选择器分组、类选择器 元素选择器 最常见的选择...

  • CSS选择器

    元素选择器 类选择器详解 ID选择器详解 属性选择器详解 后代选择器 子元素选择器 相邻兄弟选择器 CSS派生选择器:

  • CSS选择器

    CSS 元素选择器CSS 选择器分组CSS 类选择器详解CSS ID 选择器详解CSS 属性选择器详解CSS 后代...

  • ios开发:hybird开发技术一探

    在介绍hybird开发技术之前,我们先了解下在移动领域经常会听到native app、web app、hybird...

  • JSbridge的原理与封装

    一: hybird背景介绍 一般原生app发版周期长,而web版的app 开发速度快,周期短,所以hybird-H...

  • hybird -(01:hybird简介,系列对比,创建cord

    --- 廖马儿 1.hybird介绍 新浪微博有 webapp版本《百度app》 就是hybird appnat...

  • 自动化测试工具Appium(一)

    为什么选择Appium? 优点: 1、开源2、支持Native App、Hybird App、Web App;3、...

  • 初探Hybird APP

    何为HyBird APP? 首先,要了解移动APP有三个模式开发,一个是本地应用,Native APP ,还有一个...

  • hybird app开发学习笔记

    hybird app不是web app不能混淆下面是hybrid app的开发工具1PhoneGap是一个免费开发...

网友评论

    本文标题:Hybird App之选择器详解(一)

    本文链接:https://www.haomeiwen.com/subject/dcutnxtx.html