سلام! در این قسمت از مجموعه آموزشی Bootstrap 4 می خواهیم به بررسی تایپوگرافی bootstrap ، متون و حالت های مختلف نمایش آن ها بپردازیم. اطلاعات کافی در این زمینه می تواند به شما کمک کند که وب سایت خود را به آسانی و با دقت بیشتری طراحی کنید.
تنظیمات پیش فرض
در بوت استرپ 4 متون، تنظیمات پیش فرض خاص خودشان را دارند. font-size برابر با 16 پیکسل و line-heightبرابر با 1.5 است. همچنین font-family برابر با توالی زیر است:
"Helvetica Neue", Helvetica, Arial, sans-serif
به علاوه، تمام عناصر <p> دارای margin-top: 0 و margin-bottom: 1rem (برابر 16 پیکسل) هستند.
تگ های heading
تگ های <h1> تا <h6> در بوت استرپ 4 دارای وزن بالاتر (بولدتر) و اندازه ی بیشتری هستند.
به مثال زیر توجه کنید:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
<!DOCTYPE html>
<html lang="en">
<head>
<title>Bootstrap Example</title>
<meta charset="utf-8">
<meta name="viewport"content="width=device-width, initial-scale=1">
<link rel="stylesheet"href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.0/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
<h1>h1 Bootstrap heading(2.5rem=40px)</h1>
<h2>h2 Bootstrap heading(2rem=32px)</h2>
<h3>h3 Bootstrap heading(1.75rem=28px)</h3>
<h4>h4 Bootstrap heading(1.5rem=24px)</h4>
<h5>h5 Bootstrap heading(1.25rem=20px)</h5>
<h6>h6 Bootstrap heading(1rem=16px)</h6>
</div>
</body>
</html>
|
مشاهده ی خروجی در JSBin
این حالت عادیِ heading ها در بوت استرپ است اما چیزی به نام Display heading نیز وجود دارد که همان heading ها هستند با این تفاوت که اندازه ی فونت بزرگتری داشته اما وزن فونت کمتر است (لاغر تر هستند). این نوع heading ها با یکی از چهار کلاس display-1. و display-2. و display-3. و display-4. مشخص می شوند. به کد زیر توجه کنید:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
<!DOCTYPE html>
<html lang="en">
<head>
<title>Bootstrap Example</title>
<meta charset="utf-8">
<meta name="viewport"content="width=device-width, initial-scale=1">
<link rel="stylesheet"href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.0/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
<h1>Display Headings</h1>
<p>Display headings are used tostand out more than normal headings(larger font-size andlighter font-weight):</p>
<h1 class="display-1">Display1</h1>
<h1 class="display-2">Display2</h1>
<h1 class="display-3">Display3</h1>
<h1 class="display-4">Display4</h1>
</div>
</body>
</html>
|
مشاهده ی خروجی در JSBin
عنصر <small>
در بوت استرپ 4 عنصری به نام <small> وجود دارد که وظیفه اش ایجاد متن خاصی در heading ها با سایزی کوچکتر است. به مثال زیر نگاه کنید:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
<!DOCTYPE html>
<html lang="en">
<head>
<title>Bootstrap Example</title>
<meta charset="utf-8">
<meta name="viewport"content="width=device-width, initial-scale=1">
<link rel="stylesheet"href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.0/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
<h1>Lighter,Secondary Text</h1>
<p>The small element isused tocreatealighter,secondary text inany heading:</p>
<h1>h1 heading<small>secondary text</small></h1>
<h2>h2 heading<small>secondary text</small></h2>
<h3>h3 heading<small>secondary text</small></h3>
<h4>h4 heading<small>secondary text</small></h4>
<h5>h5 heading<small>secondary text</small></h5>
<h6>h6 heading<small>secondary text</small></h6>
</div>
</body>
</html>
|
مشاهده ی خروجی در JSBin
همانطور که در مثال بالا می بینید این عنصر یک متن ثانویه در همان heading ایجاد می کند (قسمتی که از بقیه ی heading کوچکتر است). این قسمت معمولا برای زیباسازی ظاهری و یا اضافه کردن توضیحاتی که اهمیت کمتری نسبت به خود heading دارند، استفاده می شوند. به طور مثال اگر heading ما «ایجاد درخواست AJAX در IE8» باشد می توانیم قسمت «در IE8» را کوچکتر بنویسیم.
عنصر <mark>
بوت استرپ 4 عنصر <mark> را بر اساس سلیقه ی خود استایل دهی می کند؛ به پس زمینه ی آن رنگ زرد کمرنگ و کمی padding! شما می توانید این موضوع را در مثال زیر ببینید:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
<!DOCTYPE html>
<html lang="en">
<head>
<title>Bootstrap Example</title>
<meta charset="utf-8">
<meta name="viewport"content="width=device-width, initial-scale=1">
<link rel="stylesheet"href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.0/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
<h1>Highlight Text</h1>
<p>Usethe mark element to<mark>highlight</mark>text.</p>
</div>
</body>
</html>
|
مشاهده ی خروجی در JSBin
عنصر <abbr>
بوت استرپ 4 عنصر <abbr> را به صورت نقطه چین هایی زیر عنصر مربوطه تغییر می دهد. در این مثال دقت کنید:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
<!DOCTYPE html>
<html lang="en">
<head>
<title>Bootstrap Example</title>
<meta charset="utf-8">
<meta name="viewport"content="width=device-width, initial-scale=1">
<link rel="stylesheet"href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.0/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
<h1>Abbreviations</h1>
<p>The abbr element isused tomark up an abbreviation oracronym:</p>
<p>The<abbr title="World Health Organization">WHO</abbr>was founded in1948.</p>
</div>
</body>
</html>
|
مشاهده ی خروجی در JSBin
عناصر <blockquote>
همانطور که میدانید عنصر <blockquote> برای ذکر نقل قول در صفحه آورده می شود؛ زمانی که می خواهیم حرف کسی را عینا تکرار کنیم. اگر به این عناصر کلاس blockquote. را اضافه کنیم بوت استرپ استایل خاص خودش را به آن می دهد:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
<!DOCTYPE html>
<html lang="en">
<head>
<title>Bootstrap Example</title>
<meta charset="utf-8">
<meta name="viewport"content="width=device-width, initial-scale=1">
<link rel="stylesheet"href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.0/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
<h1>Blockquotes</h1>
<p>The blockquote element isused topresent content from another source:</p>
<blockquote class="blockquote">
<p>For50years,WWF has been protecting the future of nature.The world's leading conservation organization, WWF works in 100 countries and is supported by 1.2 million members in the United States and close to 5 million globally.</p>
<footer class="blockquote-footer">From WWF'swebsite</footer>
</blockquote>
</div>
</body>
</html>
|
مشاهده ی خروجی در JSBin
عنصر <dl>
بوت استرپ 4 عناصر <dl> را به شکل زیر استایل دهی می کند:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
<!DOCTYPE html>
<html lang="en">
<head>
<title>Bootstrap Example</title>
<meta charset="utf-8">
<meta name="viewport"content="width=device-width, initial-scale=1">
<link rel="stylesheet"href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.0/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
<h1>Description Lists</h1>
<p>The dl element indicatesadescription list:</p>
<dl>
<dt>Coffee</dt>
<dd>-black hot drink</dd>
<dt>Milk</dt>
<dd>-white cold drink</dd>
</dl>
</div>
</body>
</html>
|
مشاهده ی خروجی در JSBin
عنصر <code>
بوت استرپ 4 کد ها (عنصر <code>) را به این شکل استایل دهی می کند:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
<!DOCTYPE html>
<html lang="en">
<head>
<title>Bootstrap Example</title>
<meta charset="utf-8">
<meta name="viewport"content="width=device-width, initial-scale=1">
<link rel="stylesheet"href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.0/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
<h1>Code Snippets</h1>
<p>Inline snippets of code should be embedded inthe code element:</p>
<p>The following HTML elements:<code>span</code>,<code>section</code>,and<code>div</code>definesasection inadocument.</p>
</div>
</body>
</html>
|
مشاهده ی خروجی در JSBin
عنصر <kbd>
عنصر <kbd> که برای توضیح کلید های کیبورد استفاده می شود در بوت استرپ 4 به شکل زیر استایل دهی می شود:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
<!DOCTYPE html>
<html lang="en">
<head>
<title>Bootstrap Example</title>
<meta charset="utf-8">
<meta name="viewport"content="width=device-width, initial-scale=1">
<link rel="stylesheet"href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.0/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
<h1>Keyboard Inputs</h1>
<p>Toindicate input that istypically entered via the keyboard,usethe kbd element:</p>
<p>Use<kbd>ctrl+p</kbd>toopen the Print dialog box.</p>
</div>
</body>
</html>
|
مشاهده ی خروجی در JSBin
عنصر <pre>
این عنصر نیز استایل خاص خودش را در بوت استرپ 4 دارد:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
<!DOCTYPE html>
<html lang="en">
<head>
<title>Bootstrap Example</title>
<meta charset="utf-8">
<meta name="viewport"content="width=device-width, initial-scale=1">
<link rel="stylesheet"href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.0/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
<h1>Multiple Code Lines</h1>
<p>Formultiple lines of code,usethe pre element:</p>
<pre>
Text inapre element
isdisplayed inafixed-width
font,andit preserves
both spaces and
line breaks.
</pre>
</div>
</body>
</html>
|
مشاهده ی خروجی در JSBin
منبع: روکسو