HTML/CSS/CSS Controls/drop cap
Содержание
- 1 Creating a drop cap using a CSS pseudo-element
- 2 Creating a drop cap with span elements and CSS
- 3 drop cap is aligned up and right, and the text is aligned to the right.
- 4 DROP CAPS: Text is large, bold, and aligned at the baseline. Subsequent lines are not indented.
- 5 DROP CAPS: The drop cap is aligned to the middle of the text. Subsequent lines are not indented.
- 6 DROP CAPS: The drop cap is offset to the top of the text. Subsequent lines are not indented.
- 7 Drop cap with lineheight, font size and background
- 8 Drop cap with span
- 9 Hanging DROP CAPS
- 10 Padded Drop Cap
- 11 This drop cap is lowered without affecting the height of the line.
Creating a drop cap using a CSS pseudo-element
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Creating a drop cap using a CSS pseudo-element</title>
<style type="text/css" media="screen">
h1+p:first-letter {
float: left;
font-size: 3em;
line-height: 1.0em;
margin-top: -3px;
margin-right: 0.15em;
}
</style>
</head>
<body>
<div id="wrapper">
<h1>This is the header</h1>
<p>this is a test. this is a test. this is a test. this is a test. </p>
</div>
</body>
</html>
Creating a drop cap with span elements and CSS
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Creating a drop cap with span elements and CSS</title>
<style type="text/css" media="screen">
h1+p {
font-weight: bold;
color: #222222;
}
.dropCap span {
font-size: 4.8em;
line-height: 1em;
}
.dropCap {
float: left;
height: 4.7em;
margin-top: -0.2em;
margin-left: -0.4em;
margin-right: 0.5em;
}
</style>
</head>
<body>
<div id="wrapper">
<h1>Article heading</h1>
<p><span class="dropCap"><span>T</span></span>is a test. this is a test.
this is a test.
this is a test.
this is a test. Sed aliquet elementum erat. Integer diam mi, venenatis non, cursus a, hendrerit at, mi. Morbi risus mi, tincidunt ornare, tempus ut, eleifend nec, risus.</p>
</div>
</body>
</html>
drop cap is aligned up and right, and the text is aligned to the right.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html"; charset="utf-8" />
<title></title>
<style type="text/css" media="Screen">
* .myDrop {
float: left;
position: relative;
top: -0.35em;
margin-top: 40px;
margin-left: 20px;
margin-right: 5px;
margin-bottom: -0.7em;
font-size: 80px;
line-height: normal;
font-weight: bold;
color: white;
background-color: black;
padding: 20px 20px 20px 20px;
border: 2px groove black;
}
</style>
</head>
<body>
<span class="myDrop">F</span>loated Drop Cap.
</body>
</html>
DROP CAPS: Text is large, bold, and aligned at the baseline. Subsequent lines are not indented.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title></title>
<style type="text/css" media="Screen">
* .myDrop {
font-size: 40px;
line-height: normal;
font-weight: bold;
vertical-align: baseline;
}
</style>
</head>
<body>
<p><span class="myDrop">A</span>bc this is a test. </p>
</body>
</html>
DROP CAPS: The drop cap is aligned to the middle of the text. Subsequent lines are not indented.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title></title>
<style type="text/css" media="Screen">
* .myDrop {
font-size: 40px;
line-height: 0.8em;
font-weight: bold;
vertical-align: middle;
background-color: red;
padding: 0 2px;
}
</style>
</head>
<body>
<p><span class="myDrop">A</span>bc this is a test. </p>
</body>
</html>
DROP CAPS: The drop cap is offset to the top of the text. Subsequent lines are not indented.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title></title>
<style type="text/css" media="Screen">
* .myDrop {
font-size: 40px;
line-height: normal;
font-weight: bold;
font-style: italic;
vertical-align: -0.45em;
color: white;
background-color: black;
background-image: url("http://www.wbex/com/style/logo.png");
padding: 0 4px;
border: 1px solid black;
}
</style>
</head>
<body>
<p><span class="myDrop">A</span>bc this is a test. </p>
</body>
</html>
Drop cap with lineheight, font size and background
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title></title>
<style type="text/css" title="text/css">
.dropCap {
float: left;
background: #aaa;
color: #ffffff;
font: 300% sans-serif;
line-height: 100%;
margin: 0 0.2em 0 0;
padding: 0.1em 0.2em;
border: 1px solid #444;
background: #b4b4b4;
}
</style>
</head>
<body>
<p><span class="dropCap">T</span>his is a test. this is a test. this is a test. this is a test. </p>
</body>
</html>
Drop cap with span
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title></title>
<style type="text/css" media="Screen">
* .indent {
position: relative;
margin-left: 100px;
margin-top: 20px;
}
* .marginal-dropcap {
position: absolute;
left: -77px;
top: -16px;
font-size: 80px;
font-weight: bold;
color: black;
background-color: red;
}
</style>
</head>
<body>
<p class="indent"><span class="marginal-dropcap">M</span>arginal Drop Cap. </p>
</body>
</html>
Hanging DROP CAPS
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title></title>
<style type="text/css" media="Screen">
* .hanging-indent {
padding-left: 50px;
text-indent: -50px;
margin-top: -25px;
}
* .hanging-dropcap {
position: relative;
top: 0.55em;
left: -3px;
font-size: 60px;
line-height: 60px;
font-weight: bold;
}
</style>
</head>
<body>
<p class="hanging-indent"><span class="hanging-dropcap">H</span>anging
</body>
</html>
Padded Drop Cap
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html"; charset="utf-8" />
<title></title>
<style type="text/css" media="Screen">
* .padded-dropcap1 {
padding-left: 5px;
padding-right: 10px;
float: left;
position: relative;
top: -0.25em;
margin-bottom: -0.2em;
margin-left: -3px;
margin-right: 3px;
font-size: 84px;
}
</style>
</head>
<body>
<p><span class="padded-dropcap1">P</span>added Floating Drop Cap. </p>
</body>
</html>
This drop cap is lowered without affecting the height of the line.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title></title>
<style type="text/css" media="Screen">
* .myDrop {
float: left;
position: relative;
top: -0.25em;
margin-left: -3px;
margin-right: 3px;
margin-bottom: -0.6em;
font-size: 80px;
}
</style>
</head>
<body>
<span class="myDrop">F</span>loated Drop Cap.
</body>
</html>