Jump to content
  • 0

Выравние разного текста по верху блока


okunev2
 Share

Question

Ребята, подскажите как текст разного размера выравнивать по верхнему краю в блоке, вот код:

#telephone {
position: absolute;
right: 0;
top: 140px;
display: block;
}

#telephone p {
color: #7540f8;
font-family: Georgia;
font-size: 18px;
font-style: italic;
font-weight: lighter;
text-align: right;
}

#telephone p em {
color: #ff0066;
font-family: Georgia;
font-size: 36px;
}


<div id="telephone"><p>+7 (xxxx) <em>xxx-xxx-xxx</em></p></div>

Спасибо

Link to comment
Share on other sites

10 answers to this question

Recommended Posts

  • 0
<!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>
<title>Test</title>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<style type="text/css">
* {
margin: 0;
padding: 0;
font: 11px "Trebuchet MS", Verdana, Tahoma, sans-serif;
}

body {
margin: 10px;
}

#telephone {
position: absolute;
right: 0;
top: 140px;
border: 1px solid;
}

#telephone em.y {
color: #ff0066;
font: 36px/36px Georgia;
vertical-align: top;
}

#telephone em.x {
color: #7540f8;
font: italic 18px/36px Georgia;
font-weight: lighter;
vertical-align: top;
}
</style>
</head>

<body>

<p id="telephone"><em class="x">+7 (xxxx) </em><em class="y">xxx-xxx-xxx</em></p>

</body>
</html>

Link to comment
Share on other sites

  • 0
<!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>
<title>Test</title>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<style type="text/css">
* {
margin: 0;
padding: 0;
font: 11px "Trebuchet MS", Verdana, Tahoma, sans-serif;
}

body {
margin: 10px;
}

#telephone {
position: absolute;
right: 0;
top: 140px;
border: 1px solid;
}

#telephone em.y {
color: #ff0066;
font: 36px/36px Georgia;
vertical-align: top;
}

#telephone em.x {
color: #7540f8;
font: italic 18px/36px Georgia;
font-weight: lighter;
vertical-align: top;
}
</style>
</head>

<body>

<p id="telephone"><em class="x">+7 (xxxx) </em><em class="y">xxx-xxx-xxx</em></p>

</body>
</html>

Спасибо, вот только есть вопрос, а что значит такая конструкция 36px/36px, первый раз вижу:

font: 36px/36px Georgia;

font: 36px/36px Georgia;

Если использовать такое решение, то в ИЕ6-7 в строке текст все равно пляшет

Link to comment
Share on other sites

  • 0
Спасибо, вот только есть вопрос, а что значит такая конструкция 36px/36px, первый раз вижу:

font: 36px/36px Georgia;

font: 36px/36px Georgia;

Если использовать такое решение, то в ИЕ6-7 в строке текст все равно пляшет

первое font-size:36px; второе line-height:36px;, разрули с помощью line-height:; и padding:; или margin:;

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. See more about our Guidelines and Privacy Policy