CSS:Tutorial two

CSS:Tutorial two

1、CSS Text

text color, text align…

Text Decoration

The text-decoration property is used to set or remove decorations from text.

The value text-decoration: none; is often used to remove underlines from links:

h1 {
   
  text-decoration: overline;
}

h2 {
   
  text-decoration: line-through;
}

h3 {
   
  text-decoration: underline;
}

Text Transformation

The text-transform property is used to specify uppercase and lowercase letters in a text.

It can be used to turn everything into uppercase or lowercase letters, or capitalize the first letter of each word:

 

p.uppercase {
    
  text-transform: uppercase;
}

p.lowercase {
    
  text-transform: lowercase;
}

p.capitalize {
    
  text-transform: capitalize;
}

Text Indentation

The text-indent property is used to specify the indentation of the first line of a text:

p {
    
  text-indent: 50px;
}

Letter Spacing

The letter-spacing property is used to specify the space between the characters in a text.

The following example demonstrates how to increase or decrease the space between characters:

 

h1 {
     
  letter-spacing: 3px;
}

h2 {
     
  letter-spacing: -3px;
}

CSS:Tutorial two

Line Height

The line-height property is used to specify the space between lines:

Text Direction

he direction property is used to change the text direction of an element:

p {
     
  direction: rtl;
}

This is right-to-left text direction

<head>
<style>
p.ex1 {
    
  direction: rtl;
}
</style>
</head>
<body>

<p>This is the default text direction.</p>
<p class="ex1"><bdo dir="rtl">This is right-to-left text direction.</bdo></p>

</body>

Word Spacing

The word-spacing property is used to specify the space between the words in a text.

Text Shadow

The text-shadow property adds shadow to text.

The following example specifies the position of the horizontal shadow (3px), the position of the vertical shadow (2px) and the color of the shadow (red):

h1 {
  text-shadow: 3px 2px red;
}

CSS:Tutorial two

 

2、CSS Fonts

Font Family

The font family of a text is set with the font-family property.

The font-family property should hold several font names as a “fallback” system. If the browser does not support the first font, it tries the next font, and so on.

Start with the font you want, and end with a generic family, to let the browser pick a similar font in the generic family, if no other fonts are available.

Note: If the name of a font family is more than one word, it must be in quotation marks, like: “Times New Roman”.

More than one font family is specified in a comma-separated list:

p {
   
  font-family: "Times New Roman", Times, serif;
}

p.sansserif {
   
  font-family: Arial, Helvetica, sans-serif;
}

Font Style

The font-style property is mostly used to specify italic text.

This property has three values:

  • normal – The text is shown normally
  • italic – The text is shown in italics
  • oblique – The text is “leaning” (oblique is very similar to italic, but less supported)

Font Size

The font-size property sets the size of the text.

Being able to manage the text size is important in web design. However, you should not use font size adjustments to make paragraphs look like headings, or headings look like paragraphs.

Always use the proper HTML tags, like <h1> – <h6> for headings and <p> for paragraphs.

The font-size value can be an absolute, or relative size.

Absolute size:

  • Sets the text to a specified size
  • Does not allow a user to change the text size in all browsers (bad for accessibility reasons)
  • Absolute size is useful when the physical size of the output is known

Relative size:

  • Sets the size relative to surrounding elements
  • Allows a user to change the text size in browsers

Note: If you do not specify a font size, the default size for normal text, like paragraphs, is 16px (16px=1em).

Set Font Size With Pixels(16px)

Set Font Size With Em(1em)

To allow users to resize the text (in the browser menu), many developers use em instead of pixels.

The em size unit is recommended by the W3C.

1em is equal to the current font size. The default text size in browsers is 16px. So, the default size of 1em is 16px.

The size can be calculated from pixels to em using this formula: pixels/16=em

h1 {
     
  font-size: 2.5em; /* 40px/16=2.5em */
}

h2 {
     
  font-size: 1.875em; /* 30px/16=1.875em */
}

p {
     
  font-size: 0.875em; /* 14px/16=0.875em */
}

Responsive Font Size

The text size can be set with a vw unit, which means the “viewport width”.

That way the text size will follow the size of the browser window:

<!DOCTYPE html>
<html>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<body>

<h1 style="font-size:10vw;">Responsive Text</h1>

<p style="font-size:5vw;">Resize the browser window to see how the text size scales.</p>

<p style="font-size:5vw;">Use the "vw" unit when sizing the text. 10vw will set the size to 10% of the viewport width.</p>

<p>Viewport is the browser window size. 1vw = 1% of viewport width. If the viewport is 50cm wide, 1vw is 0.5cm.</p>

</body>
</html>

 


Font Variant

he font-variant property specifies whether or not a text should be displayed in a small-caps font.

In a small-caps font, all lowercase letters are converted to uppercase letters. However, the converted uppercase letters appears in a smaller font size than the original uppercase letters in the text.

 
CSS:Tutorial two
 
 

3、CSS Icons

The simplest way to add an icon to your HTML page, is with an icon library, such as Font Awesome.

Add the name of the specified icon class to any inline HTML element (like <i> or <span>).

All the icons in the icon libraries below, are scalable vectors that can be customized with CSS (size, color, shadow, etc.)

Font Awesome Icons

<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.7.0/css/all.css" integrity="sha384-lZN37f5QGtY3VHgisS14W3ExzMWZxybE1SJSEsQp9S+oqd12jhcu+A56Ebc1zFSJ" crossorigin="anonymous">
</head>
<body>

<i class="fas fa-cloud"></i>
<i class="fas fa-heart"></i>
<i class="fas fa-car"></i>
<i class="fas fa-file"></i>
<i class="fas fa-bars"></i>

</body>
</html>

Bootstrap Icons

To use the Bootstrap glyphicons, add the following line inside the <head> section of your HTML page

<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
</head>
<body>

<i class="glyphicon glyphicon-cloud"></i>
<i class="glyphicon glyphicon-remove"></i>
<i class="glyphicon glyphicon-user"></i>
<i class="glyphicon glyphicon-envelope"></i>
<i class="glyphicon glyphicon-thumbs-up"></i>

</body>
</html>

Google Icons

<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="https://fonts.proxy.ustclug.org/icon?family=Material+Icons">
</head>
<body>

<i class="material-icons">cloud</i>
<i class="material-icons">favorite</i>
<i class="material-icons">attachment</i>
<i class="material-icons">computer</i>
<i class="material-icons">traffic</i>

</body>
</html>

 

 

转载于:https://www.cnblogs.com/Nyan-Workflow-FC/p/10499559.html

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/101061.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • 初识lunix_centos ubuntu

    初识lunix_centos ubuntuLinux常用快捷键    先安装rz指令,再使用rz进行导入文件    ls显示当前目录下的文件  ls-thal显示当前目录下的文件及详细信息  cd切换目录  mkdir新建目录  cp-r旧目录/新目录拷贝文件  rm-r目录删除文件  su账号名使用指定用户登录系统  tar压缩/解压命令    …

    2022年9月28日
    5
  • pycharm2021.3.3激活 mac破解方法[通俗易懂]

    pycharm2021.3.3激活 mac破解方法,https://javaforall.net/100143.html。详细ieda激活码不妨到全栈程序员必看教程网一起来了解一下吧!

    2022年3月14日
    1.7K
  • 因果图-判定表法

    因果图-判定表法一、应用场合界面中有多个控件,控件之间存在组合和限制关系,不同输入条件组合会对应不同的输出结果,为了理清每种输入条件组合和输出结果之间的对应关系,可以使用因果图/判定表法。注意:因果图/判定表法适合测试组合数量较少的情况,如果组合数量较多时,适合使用正交排列法。(更高效)二、因果图法基础1、因果图法因:输入条件果:输出结果因果图法:用画图的方式表示输入条件(因)和输出结果(果)之间的关系。2、图形符号(了解)…

    2022年8月14日
    3
  • java 字符串和整型的相互转换_java字符串转整型数组

    java 字符串和整型的相互转换_java字符串转整型数组Java中字符串转整型和整型转字符串1.字符串转整型Java代码,字符串为纯数字的情况下,调用Integer的静态方法parseInt或者valueOfJava代码,如果单个字符或字符串,需要切开转化为char字符再转化,否则按照上述方法会出现空指针异常(ASCLL码0:**48**a:**97**A:**65**)2.整型转字符串Java代码,3种方法1.字符串转整型Java代码,字符串为纯数字的情况下,调用Integer的静态方法parseInt或者valueOfpublicclass

    2022年10月9日
    2
  • 在Windows 10上安装TensorFlow及PyCharm开发环境[通俗易懂]

    在Windows 10上安装TensorFlow及PyCharm开发环境[通俗易懂]  有时候在查看官方文档时,常常看到很多的分支,所以作为开发者我们都喜欢把最佳实践总结出来。下面一起来看看如何在Windows10上安装一个TensorFlow和PyCharm开发环境。安装Anaconda  安装Anaconda以后,即可获得运行TensorFlow所需的Python运行环境。比起直接安装Python,Anaconda安装了丰富的工具,省去了不少麻烦。从http…

    2022年8月27日
    6
  • Java不可重入锁和可重入锁理解[通俗易懂]

    Java不可重入锁和可重入锁理解[通俗易懂]最近正在阅读JavaReentrantLock源码,始终对可重入和不可重入概念理解不透彻,进行学习后记录在这里。基础知识Java多线程的wait()方法和notify()方法这两个方法是成对出现和使用的,要执行这两个方法,有一个前提就是,当前线程必须获其对象的monitor(俗称“锁”),否则会抛出IllegalMonitorStateException异常,所以这两个方法必须在同步…

    2022年6月26日
    24

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号