responsive header logo with text - html

I would like for my header to change when viewed on mobile. On the big screen is shows the logo with the text beside it. On mobile I would like for the text to go below the logo and maybe even just 1 line with a bullet between. Right now when I view on mobile, the logo and text resize, but the text gets too big and falls off the screen.
Here is a link to the site:
jeepscycleclub.x10host.com
Here is my css for the #pageheader:
#pageheader {
-moz-align-items: center;
-webkit-align-items: center;
-ms-align-items: center;
align-items: center;
display: -moz-flex;
display: -webkit-flex;
display: -ms-flex;
display: flex;
-moz-justify-content: center;
-webkit-justify-content: center;
-ms-justify-content: center;
justify-content: center;
position: relative;
text-align: center;
overflow: hidden;
background-color: #2f2f37;
max-height: 15vh;
}
#pageheader img {
max-height:15vmax;
}
and my html:
<div id="pageheader">
<img src="images/pageheader.gif">
<header>
<h2 style="font-size: 3vh;">Club Info: 316-755-0909</h2>
<h2 style="font-size: 3vh;">FM 100.9 for Race PA System</h2>
</header>
</div>
This is just my test site so I can get everything done before going live with it.
Thank you in advance.

Add flex-wrap: wrap; for this. And you have to change the width/max-width, otherwise there won't be space for the text when it goes under the logo.
#pageheader {
-moz-align-items: center;
-webkit-align-items: center;
-ms-align-items: center;
align-items: center;
display: -moz-flex;
display: -webkit-flex;
display: -ms-flex;
display: flex;
-moz-justify-content: center;
-webkit-justify-content: center;
-ms-justify-content: center;
justify-content: center;
position: relative;
text-align: center;
overflow: hidden;
background-color: #2f2f37;
flex-wrap: wrap;
}
#pageheader img {
max-height:15vmax;
}
<div id="pageheader">
<img src="http://placehold.it/150x80/a0f">
<header>
<h2 style="font-size: 3vh;">Club Info: 316-755-0909</h2>
<h2 style="font-size: 3vh;">FM 100.9 for Race PA System</h2>
</header>
</div>

Related

(S)CSS Flexbox Justify-Content: Flex End Not Applying

I am trying to achieve this (my Figma mockup):
Where as I keep getting this in my real coding (text is dummy):
This is my (S)CSS for the page:
.navbarcont {
margin-top: 2em;
display: flex;
background-color: hsl(206, 97%, 13%);
border-radius: 34px;
width: 80vw;
height: 3em;
margin-left: auto;
margin-right: auto;
.links {
display: flex;
justify-content: flex-start;
margin-left: 2em;
align-items: center;
}
ul {
display: inherit;
flex-direction: row;
flex-wrap: wrap;
gap: 1em;
}
.langcont {
display: inherit;
justify-content: flex-end;
align-items: center;
}
}
And this is my React HTML:
<div className="navbarcont">
<div className="links">
<ul> {/*TODO: Remember to put icons before the a tags! (USE BOOTSTRAP ICONS!) */}
<li>
Hello
</li>
<li>
Hello
</li>
<li>
Hello
</li>
</ul>
</div>
<div className="langcont">
<div className="langtext">
<p>Language Select</p>
</div>
</div>
</div>
I really do not know where I am going wrong, or why I cannot use justify-content: flex-end; on the langcont class.
Thanks a lot for your help.
You need an additional justify-content in the navbarcontent-class
.navbarcont {
...
justify-content: space-between;
}
This will add space between the two divs and should display your elements like intended.
You have to use justify-content: space-between property on .navbarcont
.navbarcont {
display: flex;
justify-content: space-between;
...
}

Justify-content in flexbox not working in IE 11

I am trying to get an element to align to the right. I've used flexbox as I've found it easiest to align the text and any icons perfectly. The code snippet below is an example of what I am doing. The code works perfectly in Firefox and Chrome, but the justify-content is not working in IE. I already have "-ms-flex-pack" but it is not doing anything. The content is left-aligned in IE instead of being right-aligned.
.align-right {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
-webkit-box-pack: right;
-ms-flex-pack: right;
justify-content: right;
text-align:right;
}
.bold {
font-weight: 600;
}
<div class = "align-right">
Purchase Date:
<span class = "bold"> 09/10/2018</span>
</div>
You need to add flex-direction: column; to the parent element in order to justify-content in IE11
.align-right {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
-webkit-box-pack: right;
-ms-flex-pack: right;
justify-content: right;
text-align:right;
flex-direction: column; }
The following worked for me across different browsers.
.text-vcenter-right {
height: 200px;
width: 100%;
background-color: grey;
color: white;
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
-webkit-box-pack: end;
-ms-flex-pack: end;
justify-content: right;
text-align:right;
}
<div class="text-vcenter-right">Text vertically centered and justified towards right</div>

Flexbox vertical align specific content within a wrapper?

My CMS has a rather rigid setup with 2 columns with headers and content, as below:
.wrapper {
overflow: auto;
border: 1px solid #ccc;
text-align: center;
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
-ms-flex-align: center;
-webkit-align-items: center;
-webkit-box-align: center;
align-items: center;
}
.left,
.right {
float: left;
width: 45%;
padding: 5px;
}
<div class="wrapper">
<div class="left">
<h3>Title (should be aligned to top)</h3>
<div class="content">
left<br>
left<br>
left<br>
left<br>
</div>
</div>
<div class="right">
<h3>Title (should be aligned to top)</h3>
<div class="content">
right
</div>
</div>
</div>
jsFiddle
I want to make the .content of each column align vertically to the middle but keep the header h3s vertically aligned to the top.
Normally I would achieve vertical align using flexbox as such:
.wrapper {
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
-ms-flex-align: center;
-webkit-align-items: center;
-webkit-box-align: center;
align-items: center;
}
but of course this affects all elements within .wrapper.
Would anyone know a way I could 'target' the .content classes and get the same effect (keeping in mind I cannot really alter the HTML)?
This is a sort of a hack, but it works:
Remove align-items: center from the wrapper and flex:1 to the flex children left and right
Make the inner left and right container a column flexbox and center the h3 and content using justify-content:center
Use margin-bottom:auto to push both h3 to the top and allow content to stay at the middle.
See demo below:
.wrapper {
overflow: auto;
border: 1px solid #ccc;
text-align: center;
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
}
.left,
.right {
padding: 5px;
display: flex;
flex-direction: column;
justify-content: center;
flex: 1;
}
.left h3, .right h3 {
margin-bottom: auto;
}
.content {
margin-bottom: auto;
}
<div class="wrapper">
<div class="left">
<h3>
Title (should be aligned to top)
</h3>
<div class="content">
left
<br>left
<br>left
<br>left
<br>
</div>
</div>
<div class="right">
<h3>
Title (should be aligned to top)
</h3>
<div class="content">
right
</div>
</div>
</div>
check this fiddle
.wrapper {
overflow: auto;
border: 1px solid #ccc;
text-align: center;
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
-ms-flex-align: flex-start;
-webkit-align-items: flex-start;
-webkit-box-align: flex-start;
align-items: flex-start; // changed
}

Bootstrap Text Align Center Vertically

I want to make a text vertically center on 100vh height.
Here is what I've done
.about-header {
height: 100vh;
background: #000;
}
.about-header p {
font-size: 5em;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<div class="container-fluid about-header text-center">
<div class="row ">
<div class="col-md-12">
<p>Lorem Ipsum</p>
</div>
</div>
</div>
just add this below CSS:-
.about-header{
height: 100vh;
background: #000;
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-pack: center;
-ms-flex-pack: center;
justify-content: center;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
}
Your content will be vertically aligned.

Flexbox Not Creating Even Columns in Header with 3 divs

I'm trying to create a header using flexbox that features 3 divs: left = navigation, center = logo, right = social icons/links. The problem I am running into is that each div in my header is not even, so the logo is not directly centered directly in the header.
I thought if I set the flex-grow property to 1, then each section would have the same width.
Here's my code:
<html>
<head>
<style>
*, *:before, *:after {
box-sizing:border-box;
}
body {margin: 0}
.header {
display: -webkit-box;
display: -moz-box;
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
position: relative;
width: 100%;
padding:25px 20px;
background-color:#f0f0f0;
}
.header__left {
flex-grow:1;
-webkit-align-items: flex-start;
align-items: flex-start;
-webkit-justify-content: flex-start;
justify-content: flex-start;
text-align: left;
}
.header__center {
flex-grow:1;
-webkit-align-items: center;
align-items:center;
-webkit-justify-content: center;
justify-content: center;
text-align: center;
}
.header__right {
flex-grow:1;
-webkit-align-items: flex-end;
align-items: flex-end;
-webkit-justify-content: flex-end;
justify-content: flex-end;
text-align: right;
}
</style>
</head>
<body>
<header class="header">
<div class="header__left">
<nav class="header__navigation">
Menu
</nav>
</div>
<div class="header__center">
<div class="header__logo">Flexbox</div>
</div>
<div class="header__right">
<div class="header__social">
Facebook
Twitter
</div>
</div>
</header>
</body>
</html>
Use flex:1; instead of flex-grow:1;
*,
*:before,
*:after {
box-sizing: border-box;
}
body {
margin: 0
}
.header {
display: -webkit-box;
display: -moz-box;
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
position: relative;
width: 100%;
padding: 25px 20px;
background-color: #f0f0f0;
}
[class*="header__"] {
border: 1px solid green;
}
.header__left {
flex: 1;
-webkit-align-items: flex-start;
align-items: flex-start;
-webkit-justify-content: flex-start;
justify-content: flex-start;
text-align: left;
}
.header__center {
flex: 1;
-webkit-align-items: center;
align-items: center;
-webkit-justify-content: center;
justify-content: center;
text-align: center;
}
.header__right {
flex: 1;
-webkit-align-items: flex-end;
align-items: flex-end;
-webkit-justify-content: flex-end;
justify-content: flex-end;
text-align: right;
}
<header class="header">
<div class="header__left">
<nav class="header__navigation">
Menu
</nav>
</div>
<div class="header__center">
<div class="header__logo">Flexbox</div>
</div>
<div class="header__right">
<div class="header__social">
Facebook
Twitter
</div>
</div>
</header>