Reputation: 66590
I have code like this:
body, html {
height: 100%;
}
header {
font-size: 14px;
}
header h1 {
font-family: 'Oswald', sans-serif;
font-size: 4em;
text-transform: uppercase;
}
header h1, header h1:before, header h1:after {
font-weight: normal;
}
header h1:before, header h1:after {
display: inline;
font-size: 1.6em;
font-family: sans-serif;
position: relative;
top: 0.05em;
}
header h1:before {
content: "{";
}
header h1:after {
content: "}";
}
header h1 a:hover {
text-decoration: underline;
}
header a {
text-decoration: none;
}
<link href="https://fonts.googleapis.com/css?family=Oswald" rel="stylesheet">
<header>
<h1><a href="http://jcubic.pl/">Głównie JavaScript</a></h1>
</header>
<div style="width:320px">
<header>
<h1><a href="http://jcubic.pl/">Głównie JavaScript</a></h1>
</header>
</div>
And when header is smaller (on small devices) the text is wrapped into two lines but the indent of second line is to aligned with first line. How can I make both lines of text align? Do I need to use media queries for that?
Upvotes: 0
Views: 767
Reputation: 78550
You could use a combination of negative text-indent
and margin
on header h1
to achieve this. It works because text-indent
only affects the first line.
body, html {
height: 100%;
}
header {
font-size: 14px;
}
header h1 {
font-family: 'Oswald', sans-serif;
font-size: 4em;
text-transform: uppercase;
text-indent: -0.6em;
margin-left: 0.7em;
}
header h1, header h1:before, header h1:after {
font-weight: normal;
}
header h1:before, header h1:after {
display: inline;
font-size: 1.6em;
font-family: sans-serif;
position: relative;
top: 0.05em;
}
header h1:before {
content: "{";
}
header h1:after {
content: "}";
}
header h1 a:hover {
text-decoration: underline;
}
header a {
text-decoration: none;
}
<link href="https://fonts.googleapis.com/css?family=Oswald" rel="stylesheet">
<header>
<h1><a href="http://jcubic.pl/">Głównie JavaScript</a></h1>
</header>
<div style="width:320px">
<header>
<h1><a href="http://jcubic.pl/">Głównie JavaScript</a></h1>
</header>
</div>
Upvotes: 2