跳转到主要内容
你行网

Main navigation

  • 首页
  • Drupal
  • 编程与开发
  • 数据库
  • 操作系统与应用
  • 服务器与运维
  • 社区
User account menu
  • 登录

面包屑

  1. 首页

CSS 基础学习-010 css样式的三种使用方法

由 hrs, 31 三月, 2021

使用CSS样式有三种使用方法:

第一种:使用内部css样式,内部样式是在head部分的<style>元素中进行定义。

实例代码:

  1 <!doctype html>
  2 <html>
  3   <head>
  4     <meta charset="utf8">
  5     <style>
  6       p{
  7         margin-left:40px;
  8         color:blue;
  9 
 10       }
 11     </style>
 12   </head>
 13   <body>
 14     <h1>这是一个内部样式设定</h1>
 15     <p>这是第一个字段</p>
 16     <p>字段外边距为40px</p>
 17     <P>字段颜色为蓝色</p>
 18   </body>
 19 </html>
 20 

运行效果:

css-010.png

 第二种:使用外部Css样式,外部样式在 HTML 页面 <head> 部分内的 <link> 元素中进行定义。

实例代码:

 html代码:

 1 <!doctype html>
  2 <html>
  3   <head>
  4     <meta charset="utf8">
  5   <link rel="stylesheet" type="text/css" href="css/style-10.css">
  6   
  7   </head>
  8   <body>
  9     <h1>这是一个外部样式设定</h1>
 10 
 11     <p>字段外边距为30px</p>
 12     <P>字段颜色为红色</p>
 13   </body>
 14 </html>



外部css样式代码:文件名为:style-10.css

 1 P{
  2 color:red;
  3 margin-left:30px
  4 
  5 }
~                                                                               
~           

运行效果:

css-010-2.png

第三种:使用行内css样式,内部样式在 HTML 页面的 <head> 部分内的 <style> 元素中进行定义

实例代码:

  1 <!doctype html>
  2 <html>
  3   <head>
  4     <meta charset="utf8">
  5   
  6   
  7   </head>
  8   <body>
  9     <h1>这是一个行内样式设定</h1>
 10 
 11     <p style="color:red;text-align:left;">字段字体为红色,左对齐</p>
 12     <P style="font-size:30px;">字段字体大小为30px</p>
 13   </body>
 14 </html>
 15 

运行效果:

css-010-3.png

 

  • 登录或注册以发表评论
  • 64 次浏览
内容类型分类
编程与开发
文章归类
前端开发

文章标签

  • CSS

评论

最新文章

  • 内容审核通知 content_moderation_notifications 模块简介
  • 调度程序 scheduler 模块简介
  • 工作流当中的草稿,已发布,很好理解,已归档是怎么理解。
  • 你行网 https://www.dwoke.com seo 关键词
  • brew 是什么命令
  • drupal 9 或 drpal 10 国内内容分享模块 Will Nice social share
  • Views Slideshow - Views Vanilla JavaScript Slideshow (VVJS) 简介和安装方法
  • drupal 11 安装statistics 统计模块
  • drupal11 扩展中找不到Statistics模块
  • drupal11 设置中的“总结摘要”和“切边的” 有什么区别

标签云

adsenseAIapacheaptbadblocksbreadcrumbbrewcentoscertbotckeditorcommandcomposercookiecsharpCSScurlC语言DDEVdiffdnsdockerDreamweaverDrupaldrupal 7drupal 8drupal 9drupal10drupal 11drushExcelfirewalldfirmwareflameshotformgimpgitgzipHTMLHTML5httpdhttp验证inputipjavaJavaScriptJavaSrciptkernelKVMLinuxmavenmbstringmod_expires 模块Mysqlnerdtreenetstatnetworknginxnpmpasswordphpphpmyadminphp扩展RFIDRSSselinuxSEOsharesimple_adsensesshsslStatisticssuperfishsurroundtagcloudstitleubuntuuploadprogressvimVPNVUEWireGuardwpsxdebugyoutubeyumzip主题(theme)二进制五笔分类术语压缩解压哈希值声音字段密码工作流快捷键摄影权限果树种植标签优化模块(module)源地址版本号电子秤电脑基础电脑技巧短信验证端口简介算法网站备份网站运营翻译英语表单视图(views)计算机基础赚钱超五类线网线邮件验证重定向重定向,301错误颜色

相关文章

  • php json_encode 函数将编码值转为json格式
  • php 用户自定义回调函数实例
  • php 回调函数实例
  • 匿名函数(Anonymous Functions)详解
  • 如何去掉input和button标签中间有缝隙
  • PHP 中的四种标量数据类型
  • php 语言的四种标记风格
  • date_default_timezone_set 设置php服务器的默认时区
  • php8.3 的扩展模块简略说明
  • <input>` 类型的定义和用途的简要说明
RSS源

关于我们

  • 你行网简介
  • 关于我们
  • 版权声明

网站相关

  • 社区论坛
  • 网址导航
  • 网站地图
  • 联系我们

友情链接

  • 英文学习

友情链接2

  • drupal 大学
  • 水滴间
  • 爱码网
  • Apache

友情链接3

  • MySQL
  • php
  • drupalcode

友情链接4

  • Drupal 中国
  • Drupal 老葛
  • 宁浩网
  • drupal 台湾
Copyright © 2019 - 2021 你行网 版权所有  粤ICP备19072650号-1