//HTML - How to horizontally center the text of an h1 in the middle of the screen if it shares the div with...
up vote
0
down vote
favorite
My html code for this part looks like this:
<div class="container navbar id="navbar">
<div class="row banner">
<span class="one-tenth column logo">
<i class="fab fa-3x fa-cuttlefish"><a href="index.html"></a></i>
</span>
<h1 class="nine-tenths column"><strong>Title</strong></h1>
</div>
</div>
so far I tried this in css:
.banner{
display: -webkit-flex;
display: flex;
align-items: center;
justify-content: center;
padding:25px 0;
text-align:center;
}
I am using my own grid system in which I defined:
.one-tenth {
width: calc(100% /10 * 1);
}
.nine-tenths {
width: calc(100% / 10 * 9);
}
In addition to all the other rules necessary for a grid system.
My problem is now that my h1 still doesn't display in the middle of the screen/banner (banner width is 100% so its center would also be the middle of the screen).
It displays in the middle of its column which is not the middle of the screen.
It is to keep in mind that the h1 shares its container banner with another column which has the width 10%. H1 itself is a column of 90% width.
html css text screen center
add a comment |
up vote
0
down vote
favorite
My html code for this part looks like this:
<div class="container navbar id="navbar">
<div class="row banner">
<span class="one-tenth column logo">
<i class="fab fa-3x fa-cuttlefish"><a href="index.html"></a></i>
</span>
<h1 class="nine-tenths column"><strong>Title</strong></h1>
</div>
</div>
so far I tried this in css:
.banner{
display: -webkit-flex;
display: flex;
align-items: center;
justify-content: center;
padding:25px 0;
text-align:center;
}
I am using my own grid system in which I defined:
.one-tenth {
width: calc(100% /10 * 1);
}
.nine-tenths {
width: calc(100% / 10 * 9);
}
In addition to all the other rules necessary for a grid system.
My problem is now that my h1 still doesn't display in the middle of the screen/banner (banner width is 100% so its center would also be the middle of the screen).
It displays in the middle of its column which is not the middle of the screen.
It is to keep in mind that the h1 shares its container banner with another column which has the width 10%. H1 itself is a column of 90% width.
html css text screen center
Make h1 eight-tenths and put an empty one-tenth behind it. Then just use text-align: center for the h1.
– Gerard
Nov 9 at 16:55
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
My html code for this part looks like this:
<div class="container navbar id="navbar">
<div class="row banner">
<span class="one-tenth column logo">
<i class="fab fa-3x fa-cuttlefish"><a href="index.html"></a></i>
</span>
<h1 class="nine-tenths column"><strong>Title</strong></h1>
</div>
</div>
so far I tried this in css:
.banner{
display: -webkit-flex;
display: flex;
align-items: center;
justify-content: center;
padding:25px 0;
text-align:center;
}
I am using my own grid system in which I defined:
.one-tenth {
width: calc(100% /10 * 1);
}
.nine-tenths {
width: calc(100% / 10 * 9);
}
In addition to all the other rules necessary for a grid system.
My problem is now that my h1 still doesn't display in the middle of the screen/banner (banner width is 100% so its center would also be the middle of the screen).
It displays in the middle of its column which is not the middle of the screen.
It is to keep in mind that the h1 shares its container banner with another column which has the width 10%. H1 itself is a column of 90% width.
html css text screen center
My html code for this part looks like this:
<div class="container navbar id="navbar">
<div class="row banner">
<span class="one-tenth column logo">
<i class="fab fa-3x fa-cuttlefish"><a href="index.html"></a></i>
</span>
<h1 class="nine-tenths column"><strong>Title</strong></h1>
</div>
</div>
so far I tried this in css:
.banner{
display: -webkit-flex;
display: flex;
align-items: center;
justify-content: center;
padding:25px 0;
text-align:center;
}
I am using my own grid system in which I defined:
.one-tenth {
width: calc(100% /10 * 1);
}
.nine-tenths {
width: calc(100% / 10 * 9);
}
In addition to all the other rules necessary for a grid system.
My problem is now that my h1 still doesn't display in the middle of the screen/banner (banner width is 100% so its center would also be the middle of the screen).
It displays in the middle of its column which is not the middle of the screen.
It is to keep in mind that the h1 shares its container banner with another column which has the width 10%. H1 itself is a column of 90% width.
html css text screen center
html css text screen center
asked Nov 9 at 16:34
Joshua
1
1
Make h1 eight-tenths and put an empty one-tenth behind it. Then just use text-align: center for the h1.
– Gerard
Nov 9 at 16:55
add a comment |
Make h1 eight-tenths and put an empty one-tenth behind it. Then just use text-align: center for the h1.
– Gerard
Nov 9 at 16:55
Make h1 eight-tenths and put an empty one-tenth behind it. Then just use text-align: center for the h1.
– Gerard
Nov 9 at 16:55
Make h1 eight-tenths and put an empty one-tenth behind it. Then just use text-align: center for the h1.
– Gerard
Nov 9 at 16:55
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
I think I got it, what you can do is add to the title a margin-right the same size as the .one-tenth width, in order to do this you need to wrap the title in a span tag
<div class="container navbar id="navbar">
<div class="row banner">
<span class="one-tenth column logo">
<i class="fab fa-3x fa-cuttlefish"><a href="index.html"></a></i>
</span>
<h1 class="nine-tenths column"><strong><span class="span">Title</span></strong></h1>
</div>
</div>
and then you need to add this class to the css
.banner .span{
margin-right: calc(100% /10 * 1);
}
You can check it here, let me know if that help you!
thank you so much will try it tomorrow.. I think too that you got it :) sounds like it works at least - sadly cant upvote yet since i am new here
– Joshua
Nov 9 at 19:12
Don't worry, I'm glad to help!
– MartinBA
Nov 10 at 14:59
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
I think I got it, what you can do is add to the title a margin-right the same size as the .one-tenth width, in order to do this you need to wrap the title in a span tag
<div class="container navbar id="navbar">
<div class="row banner">
<span class="one-tenth column logo">
<i class="fab fa-3x fa-cuttlefish"><a href="index.html"></a></i>
</span>
<h1 class="nine-tenths column"><strong><span class="span">Title</span></strong></h1>
</div>
</div>
and then you need to add this class to the css
.banner .span{
margin-right: calc(100% /10 * 1);
}
You can check it here, let me know if that help you!
thank you so much will try it tomorrow.. I think too that you got it :) sounds like it works at least - sadly cant upvote yet since i am new here
– Joshua
Nov 9 at 19:12
Don't worry, I'm glad to help!
– MartinBA
Nov 10 at 14:59
add a comment |
up vote
0
down vote
I think I got it, what you can do is add to the title a margin-right the same size as the .one-tenth width, in order to do this you need to wrap the title in a span tag
<div class="container navbar id="navbar">
<div class="row banner">
<span class="one-tenth column logo">
<i class="fab fa-3x fa-cuttlefish"><a href="index.html"></a></i>
</span>
<h1 class="nine-tenths column"><strong><span class="span">Title</span></strong></h1>
</div>
</div>
and then you need to add this class to the css
.banner .span{
margin-right: calc(100% /10 * 1);
}
You can check it here, let me know if that help you!
thank you so much will try it tomorrow.. I think too that you got it :) sounds like it works at least - sadly cant upvote yet since i am new here
– Joshua
Nov 9 at 19:12
Don't worry, I'm glad to help!
– MartinBA
Nov 10 at 14:59
add a comment |
up vote
0
down vote
up vote
0
down vote
I think I got it, what you can do is add to the title a margin-right the same size as the .one-tenth width, in order to do this you need to wrap the title in a span tag
<div class="container navbar id="navbar">
<div class="row banner">
<span class="one-tenth column logo">
<i class="fab fa-3x fa-cuttlefish"><a href="index.html"></a></i>
</span>
<h1 class="nine-tenths column"><strong><span class="span">Title</span></strong></h1>
</div>
</div>
and then you need to add this class to the css
.banner .span{
margin-right: calc(100% /10 * 1);
}
You can check it here, let me know if that help you!
I think I got it, what you can do is add to the title a margin-right the same size as the .one-tenth width, in order to do this you need to wrap the title in a span tag
<div class="container navbar id="navbar">
<div class="row banner">
<span class="one-tenth column logo">
<i class="fab fa-3x fa-cuttlefish"><a href="index.html"></a></i>
</span>
<h1 class="nine-tenths column"><strong><span class="span">Title</span></strong></h1>
</div>
</div>
and then you need to add this class to the css
.banner .span{
margin-right: calc(100% /10 * 1);
}
You can check it here, let me know if that help you!
edited Nov 12 at 2:15
answered Nov 9 at 18:38
MartinBA
7061113
7061113
thank you so much will try it tomorrow.. I think too that you got it :) sounds like it works at least - sadly cant upvote yet since i am new here
– Joshua
Nov 9 at 19:12
Don't worry, I'm glad to help!
– MartinBA
Nov 10 at 14:59
add a comment |
thank you so much will try it tomorrow.. I think too that you got it :) sounds like it works at least - sadly cant upvote yet since i am new here
– Joshua
Nov 9 at 19:12
Don't worry, I'm glad to help!
– MartinBA
Nov 10 at 14:59
thank you so much will try it tomorrow.. I think too that you got it :) sounds like it works at least - sadly cant upvote yet since i am new here
– Joshua
Nov 9 at 19:12
thank you so much will try it tomorrow.. I think too that you got it :) sounds like it works at least - sadly cant upvote yet since i am new here
– Joshua
Nov 9 at 19:12
Don't worry, I'm glad to help!
– MartinBA
Nov 10 at 14:59
Don't worry, I'm glad to help!
– MartinBA
Nov 10 at 14:59
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53229747%2fhtml-how-to-horizontally-center-the-text-of-an-h1-in-the-middle-of-the-scree%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Make h1 eight-tenths and put an empty one-tenth behind it. Then just use text-align: center for the h1.
– Gerard
Nov 9 at 16:55