Home Web Front-end CSS Tutorial Beautify HTML paragraph text Ⅰ_Experience exchange

Beautify HTML paragraph text Ⅰ_Experience exchange

May 16, 2016 pm 12:05 PM
beautify

上篇已经说了在第五篇会开始讲CSS,刚开始讲不能讲得复杂,我们还是由浅入深,一步步来。还是那句话:先用起来,然后再去研究。即然我们第一篇讲的是段落,那我们这篇初讲CSS当然也还是要从段落开始,让我们的段落先漂亮起来。

在没有讲CSS之前我们先去想一下什么样的段落才看起来才是最舒服的?如果大家一时还没有什么想法或是还不清楚如何去分析这个问题不妨先看一下《网页设计技巧系列之一 浅谈文本排版》。不论如何至少我们的小学老师告诉我们每一段的第一行应该空两个字。这可能是我们接受到的第一个关于如何划分段落的方法。并且可能更多人已经产生了思维定式,认为段落必需要首行空两格。而我则认为区分段落的首要素同段距,其次才能是段落首行的处理。而首行的处理是否只有缩进两字呢?我个人认为不是,因为我们还可以用“首字下沉”、“首行突出两字”等来表现。有人会说:“首字下沉我就见过,比如作者的博客就用了这个效果,但是首行突出两字似乎有点奇怪。”然而事实上首行突出两字必不是作者发明的,在中国古代的奏本上就常采用这种格式,不同的是因为他们常需要在行首写上一些颂语,而要表达这种颂语就需要抬高其地位,比如“君”“圣上”等字眼,所以才会突出两字,久之则形成了一种特别的排版形式,这种形式现在的文体是用得少了,不过大家可以多多了解一下,方便以后表达不同的文体时可以用得着。

Beautify HTML paragraph text Ⅰ_Experience exchange

即然段距是段落区分的第一要素,那么我们就先来解决这个段距的的样式问题。即然是一段一段的那么我们每一段都是由一组

组合而成的,而我们的CSS只要通过对这个段落标签的描述就可以实现我们所需要的效果了。那么基本形式是:

p {这里是样式描述内容}

我们注意到了,在CSS中这个段落标签是不需要加尖括号的,只需要一个"p"即可以了。所有的标签都是如此处理。那么我们需要给每个段落设个段距,这里我们有两个描述属性,一个是padding,另一个是margin,这两个表现的效果看起来有点像,但是却有着本质上的区别,如果我们把段落表示成盒子,在这个盒子里装着一些东西,padding就是这些东西与盒子内侧边的距离,而margin则是盒子与盒子之间的距离。这里很显然,我们里应该是使用margin。写法是:margin:1em 0;这是一种简写的方法,如果写全了应该是:margin-top:1em; margin-right:0; margin-bottom:1em; margin-left:0;  这很明显太冗余了,所以一般我们通常是写成:margin:1em 0 1em 0; 这里的顺序是上右下左,由于上下的数值是一样的,左右的数值是一样的,那么就可以再缩写成:margin:1em 0; 这里的em是指相对长度单位,相对于当前对象内文本的字体尺寸。有关于单位的知识请查阅沈苏小雨编制的《CSS2.0中文手册》。那为什么要用em而不用px或是pt呢,这是因为我们现在的流览器大多都有字体放大的功能,这也是方便读者的能看得更清楚文字内容,那么如果我们用px来设定段距那么当字体放大时段距却不会变动,那么当放大到一定数值时这个段距的特性也就不存在了。所以我们使用em这个单位,也就是希望当字体变大时段距也跟着相应变大,方便识别。

Beautify HTML paragraph text Ⅰ_Experience exchange

这里值得注意的是,当我们使用margin的时候两个段落之间的margin会有重叠,那么看上图中右侧的图我们可以发现在两段之间的margin是被重叠了原本应该是两个高度相加的结果还是一个高度,但是上图中间的示意padding却没有重叠他们的高度是相加的,这点大家要注意到,这不是什么BUG,而是一种特性。那么我们就写一句CSS来设定我们的段落:

p {margin:1em 0;}

When we talk about paragraph spacing, we naturally talk about line spacing. Friends who have read "Web Design Skills Series One: A Brief Talk on Text Layout" will understand the importance of line spacing. So have you set the line spacing for your pages? How do you set it? There is a special attribute for setting line spacing: line-height, which should be called line height. Because what we want to set is the height of a row, not the distance between rows. This is why we always find that the data for setting line spacing in Photoshop is different from the values ​​set for web pages. But line spacing can still be generated by the line height we set, so the methods are different, but the goal is the same. Generally, our line height must exceed the font height, otherwise the lines will overlap. Of course, we do not rule out using this method to create some special effects, but at least when reading the text, we need the lines to be clear. The line spacing should not be too large. If it is too large, reading efficiency will be low. If it is too small, it is easy to read the wrong line. Therefore, the general line height should not exceed the height of two characters. The most commonly used Zhenzhi is between 1.6em and 1.8em. If the width is large, we need to increase the line spacing, otherwise we will easily read the wrong line. If the line spacing is too large when the width is small, reading efficiency will be lost. Then let’s add some CSS to the paragraph just now and mark our line spacing:

p {margin:1em 0; line-height:1.6em; }

This completes the basic paragraph settings. If you need to add a first line indent to this paragraph, you can also set the font, font size, font style, color, etc. for this paragraph:

p {margin:1em 0; text-indent:2em; font:normal normal 12px/1.6em "宋体"; color:#000; }

The font attributes here are also in abbreviated form, the order is: "font : font-style || font-variant || font-weight || font-size || line-height || font-family ", these The knowledge is described in Shen Su Xiaoyu's CSS2.0 Chinese manual. I won’t repeat it here. The color here is the color of the text. The value after # should be 6 digits. You can directly copy the value in the Photoshop color picker. But we also often abbreviate. The abbreviation is that when the values ​​of the odd and even bits are the same, they can be combined into a 3-digit color value. For example: #4488cc, which can be abbreviated to #48c. If you need to highlight the first text, you not only need to set the value of text-indent to a negative value, but also need to modify the value of padding, because the protrusion is beyond the content area. If the padding If there is no space in the area, the two highlighted words cannot be displayed. Then let’s give another CSS that highlights two words in the first line

p {margin:1em 0; padding:0 0 0 2em; text-indent:-2em; font:normal normal 12px/1.6em "宋体"; color:#000; } SPAN>

The content about beautifying paragraph text will be discussed here. The next article will explain how to make a drop cap and what to pay attention to!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Use ThinkPHP6 to implement a beautiful 404 page Use ThinkPHP6 to implement a beautiful 404 page Jun 20, 2023 am 11:06 AM

As the Internet develops, many websites or applications have gradually become more complex. When users use it, they often encounter error pages, the most common of which is the 404 page. The 404 page means that the page being accessed does not exist and is a common error page. For websites or applications, a beautiful 404 page can greatly improve the user experience. In this article, we will introduce how to use ThinkPHP6 to quickly implement a beautiful 404 page. Create a route First, we need to create an err in the route folder

Beautify your user interface with new JavaFX CSS stylesheets in Java 13 Beautify your user interface with new JavaFX CSS stylesheets in Java 13 Jul 30, 2023 pm 02:49 PM

Use the new JavaFXCSS style sheet in Java13 to beautify the user interface Introduction: In software development, the beauty and ease of use of the user interface are crucial to improving the user experience. JavaFX is a modern, expressive interface technology on the Java platform that provides rich UI components and functions. In order to make the user interface more beautiful, JavaFX provides CSS style sheets to beautify and customize the interface. In Java13, JavaFX introduced new CSS style sheets,

How to beautify word How to beautify word Mar 19, 2024 pm 08:31 PM

When we edit word documents, we always hope to make the documents more beautiful and beautiful. However, when it comes to word beautification, many people think of making the fonts and colors more personalized, and adjusting the margins and line spacing. Wait, in fact, we can make word more beautiful through more operations. For example, we can make word documents more beautiful by inserting pictures, modifying borders, etc. Next we will try to use border patterns to make word documents more beautiful, let’s learn together! First, open a new Word document, and then find the [Paragraph] tool under the [Home] tab. Next, click the [Border] option, as indicated by the red arrow in the image. 2. After we click, the system will automatically pop up a drop-down selection

How to beautify training PPT so that the "ugly duckling" can become a "white swan" How to beautify training PPT so that the "ugly duckling" can become a "white swan" Mar 19, 2024 pm 09:01 PM

Most institutions will use courseware when training people in certain aspects. Excellent lecturers paired with high-quality PPT can better help students understand. How to modify your PPT? This article will tell you the answer. Let’s take a look first. Excellent courseware has the same characteristics: clear logic, concise text, and rich pictures and texts. 1. Let’s first find a picture as an example. You can observe it first. Through observation and analysis, we can find the following problems: 2. Let’s take the first step in making modifications - find styles (you can browse some websites to find inspiration, such as Huaban.com) 3. The second step is to find color matching . You can draw colors based on the styles you find. 4.Here we use calligraphy

How to implement scroll bar beautification in Vue How to implement scroll bar beautification in Vue Nov 07, 2023 am 08:57 AM

How to beautify scroll bars in Vue In the process of developing web applications, we often encounter the need to beautify scroll bars. The default scroll bar style may not meet our design requirements, so we need to use some CSS techniques to beautify the scroll bar. This article will introduce how to implement scroll bar beautification in Vue and provide specific code examples. First, we need to install a plug-in for beautifying scroll bars. Currently the more commonly used plug-ins include PerfectScrollbar and SimpleBa

How to beautify the win10 desktop. The editor will teach you how to beautify it. How to beautify the win10 desktop. The editor will teach you how to beautify it. Jan 11, 2024 pm 08:15 PM

It has been a few days since win10 was released and upgraded. There will definitely be a lot of things that are not used to the new desktop and new experience, but some people don’t like it. Also, win10 has just been released and the desktop is not perfect yet. For students with obsessive-compulsive disorder, it looks messy. Friends who want other systems or more desktops, don’t miss it. Below, the editor will share with you how to beautify win10. The desktop is the first interface we see every time we turn on the computer. Many computer enthusiasts like to beautify the desktop, but most of them only stop at changing the desktop wallpaper, icons, or fonts. Although win10 is a new system, many new features are very convenient for everyone, but there are some optimizations that are not very satisfactory. For this reason, the editor has brought a win10 desktop

Essential skills for beautifying UI interface: Sharing experience in CSS development projects Essential skills for beautifying UI interface: Sharing experience in CSS development projects Nov 02, 2023 pm 01:00 PM

Essential skills for beautifying UI interfaces: CSS development project experience sharing In today’s digital era, user interface (UI) has become a crucial part of software and website development. An attractive and easy-to-use user interface can increase the user's favorable impression of the product or service and enhance the user experience. CSS, as a technology used to define web page styles, plays a vital role in beautifying the UI interface. This article will share some experience and essential skills in CSS development projects to help you create an elegant and attractive user interface.

Beautify the website's top page link button: use the get_pages() method Beautify the website's top page link button: use the get_pages() method Sep 09, 2023 pm 10:45 PM

If you followed my previous tutorial, you will now have a theme (or subtheme) on your site that contains links to the top-level pages in the header of your site. I created a 26 child theme and this is what my links look like now: In this tutorial I'm going to show you how to add some CSS to your theme to make those links a little nicer. Let's start by removing bullets and adding floats. Remove the bullet points and add a floating stylesheet to open the theme. If you created a child theme it will be empty, but if you are using your own theme I recommend adding this style in the section of your stylesheet that holds the header style. Code review for output page link (if there is a page to be linked): <ulclass=&quo

See all articles