//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.










share|improve this question






















  • 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

















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.










share|improve this question






















  • 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















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.










share|improve this question













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






share|improve this question













share|improve this question











share|improve this question




share|improve this question










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




















  • 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














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!






share|improve this answer























  • 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











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














 

draft saved


draft discarded


















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

























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!






share|improve this answer























  • 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















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!






share|improve this answer























  • 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













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!






share|improve this answer














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!







share|improve this answer














share|improve this answer



share|improve this answer








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


















  • 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


















 

draft saved


draft discarded



















































 


draft saved


draft discarded














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





















































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







Popular posts from this blog

Schultheiß

Liste der Kulturdenkmale in Wilsdruff

Android Play Services Check