css标题样式_CSS的标题集样式
css标题样式
In this tutorial I’m hoping to give you some ideas and inspiration for your current and future projects!
在本教程中,我希望为您当前和将来的项⽬提供⼀些想法和启发!
Today, we are going to talk about headings and titles. When you put some content on the web (or on a paper), you have to set up some kind of structure. And this is where you need headings: to give sense to your content.
今天,我们将讨论标题和标题。 当您在⽹络上(或纸上)放置⼀些内容时,必须建⽴某种结构。 这就是
您需要标题的地⽅:使您的内容有意义。
We all know how difficult it is to find the appropriate title for the right content, and frankly I’m not good at it so this won’t be the point of the article. Instead, we are going to talk about design.
我们都知道到合适内容的适当标题很困难,并且坦率地说我不擅长,所以本⽂不会重点讨论。 相反,我们将讨论设计。
How to design a good title, or a good arborescence of titles? I didn’t think much about it until then so I thought it could be a nice exercise, so here we are. I tried to create a few sets of headings, each one with its own feeling.
如何设计⼀个好标题,或好标题树? 在那之前我没有考虑太多,所以我认为这可能是⼀个不错的练习,所以我们来了。 我尝试创建⼀些标题,每个标题都有⾃⼰的感觉。
A few notes before we start:
我们开始之前的⼀些注意事项:
Every font used in this tutorial is a free font from .
本教程中使⽤的每种字体都是的免费字体。
You won’t see any vendor prefixes in the CSS snippets, but you will, of course, find them in the files.
您不会在CSS⽚段中看到任何供应商前缀,但是您当然会在⽂件中到它们。
I use the box-model where [width] = [element-width] + [padding] + [borders]. I activate it with the following snippet:
我使⽤其中[宽度] = [元素宽度] + [填充] + [边框]的盒⼦模型。 我使⽤以下代码段激活它:
*, *:after, *:before {
box-sizing: border-box;
}
I don’t think there is much need for an explanation about the markup used in the demos: I used 4 titles, from h1 to h4.
我认为没有必要对演⽰中使⽤的标记进⾏解释:我使⽤了4种标题,从h1到h4。
Why not h5 and h6 you say? Simply because it’s not very usual to have such a depth for normal websites. But if you have one which requires those levels of headings, please be sure to include some styles for them as well.
为什么不说h5和h6? 仅仅是因为在普通⽹站上拥有如此⾼的深度并不是很平常。 但是,如果您有⼀个需要这些标题级别的标题,请确保也为它们添加⼀些样式。
关于垂直节奏的⼏句话 (A few words on vertical rhythm)
什么是垂直节奏?(What is vertical rhythm?)
Vertical rhythm is a very important thing when it comes to web design. It is the concept implying consistent spacing
between elements on a page, especially typographic elements.
当涉及到⽹页设计时,垂直节奏⾮常重要。 此概念表⽰页⾯上的元素(尤其是印刷元素)之间的间距⼀致。
When you write a blog post which is divided into multiple sections like this one, you may want to have proportional spacing around each element, such as titles, paragraphs, images, lists, etc.
当您写博客⽂章时,像这样分成多个部分,您可能希望每个元素(例如标题,段落,图像,列表等)周围都有成⽐例的间距。
Let me quote Richard Rutter from his :
让我引⽤理查德·鲁特(Richard Rutter)在他:
On the Web, vertical rhythm – the spacing and arrangement of text as the reader descends the page – is contributed to by three factors: font size, line height and margin or padding. All of these factors must calculated with care in order that the rhythm is maintained.
在⽹络上,垂直节奏(即阅读者下移页⾯时⽂本的间距和排列)是由三个因素造成的:字体⼤⼩,⾏⾼,边距或填充。 为了保持⼼律,必须仔细计算所有这些因素。
Since I’m not a vertical rhythm expert, I decided to not reinvent the wheel and go with a few lines of CSS as a default base to write my demos.
由于我不是垂直节奏专家,所以我决定不重新发明轮⼦,⽽是使⽤⼏⾏CSS作为默认⽰例来编写演⽰。
CSS中的垂直节奏 (Vertical rhythm in CSS)
h1 {
font-size: 36px;
line-height: 40px;
}
h2 {
font-size: 30px;
line-height: 40px;
}
h3 {
font-size: 24px;
line-height: 40px;
}
h4 {
font-size: 18px;
line-height: 20px;
}
/* Won't be used here */
h5 {
font-size: 14px;
line-height: 20px;
}
h6 {
font-size: 12px;
line-height: 20px;
}
I also gave a few styles to paragraphs to make them fit to the headings. But we are going to focus on the headings only here.
我还为段落提供了⼀些样式,使它们适合标题。 但是,我们将仅在此处关注标题。
Now that we have covered the basics of our exercise, we can create a few sets of headings!
现在,我们已经涵盖了练习的基础知识,我们可以创建⼀些标题!
Note that each heading will have its styles defined individually, so you will see a lot of repetition of styles among the headings. When you write your styles, you should of course summarize them to avoid repetition.
请注意,每个标题将分别定义其样式,因此您将在标题中看到很多样式重复。 在编写样式时,您当然应该总结⼀下样式,以避免重复。例⼦1 (Example 1)
Let’s start with something pretty simple. Not much involved here, just a few font styles.
让我们从⼀些简单的事情开始。 这⾥涉及的并不多,只是⼀些字体样式。
Fonts used: Ultra (sans-serif), Orienta (sans-serif).
使⽤的字体: Ultra(sans-serif),Orienta(sans-serif)。
.demo-1 .main h1 {
margin: 1em 0 0.5em 0;
color: #343434;
font-weight: normal;
font-family: 'Ultra', sans-serif;
font-size: 36px;
line-height: 42px;
text-transform: uppercase;
text-shadow: 0 2px white, 0 3px #777;
}
.demo-1 .main h2 {
borderboxmargin: 1em 0 0.5em 0;
color: #343434;
font-weight: normal;
font-size: 30px;
line-height: 40px;
font-family: 'Orienta', sans-serif;
}
.demo-1 .main h3 {
margin: 1em 0 0.5em 0;
color: #343434;
font-size: 22px;
line-height: 40px;
font-weight: normal;
text-transform: uppercase;
font-family: 'Orienta', sans-serif;
letter-spacing: 1px;
font-style: italic;
}
.demo-1 .main h4 {
margin: 1em 0 0.5em 0;
color: #343434;
font-size: 18px;
line-height: 20px;
font-weight: normal;
font-family: 'Orienta', sans-serif;
}
Okay, it was pretty straightforward. Let’s try something a little more detailed.
好吧,这很简单。 让我们尝试⼀些更详细的内容。
例⼦2 (Example 2)
This examples shows how to add something to the background of your heading, be it solid color or even an image. The large inset white box shadow for the h1 will ensure that the image does not “collide” with the headline text when we view it on a small screen. The left padding has a percentage value for the same reason: when the viewport becomes very small, we want to keep the padding relative to the width, i.e. keep it fluid.
本⽰例说明了如何在标题背景中添加某些内容,⽆论是纯⾊还是图像。 h1的较⼤的插⼊⽩框阴影将确保当我们在⼩屏幕上查看图像时,图像不会与标题⽂本“冲突”。 出于相同的原因,左侧的填充具有百分⽐值:当视⼝变得⾮常⼩时,我们要相对于宽度保持填充,即保持其流畅。
Fonts used: Titillium Web (sans-serif), Muli (sans-serif).
使⽤的字体: Titillium Web(sans-serif),Muli(sans-serif)。
CSS (The CSS)
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论