Situation: I have a div with flex and h1 and h3 children inside it.
Problem: The flex-wrap does not apply correctly to the h1 element.
What I tried: I have tried applying width, and max-width to the container but the h1 tag doesn't wrap when resized but the h3 does.
I've tried to apply height as well. I've applied the flex properties to other containers but no matter what the h1 won't move. The h1 doesn't wrap to the other line. It just stays put and gets engulfed by the overflow when the browser resizes.
Expected result: the h1 must wrap its letters when resizing the screen.
Snippet:
* {
box-sizing: border-box;
font-family: Francois One;
}
body {
margin: 0;
font-family: Francois One;
font-size: 1rem;
line-height: 1.5;
overflow-x: hidden;
}
.v-header {
height: 100vh;
width: 100%;
display: flex;
align-items: center;
justify-content: center;
}
.container {
padding-left: 1rem;
padding-right: 1rem;
margin: auto;
text-align: center;
}
.fullscreen-img-wrap {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100vh;
overflow: hidden;
}
.fullscreen-img-wrap img {
min-width: 100%;
min-height: 100vh;
}
.header-overlay {
height: 100vh;
width: 100%;
position: absolute;
top: 0;
left: 0;
background: rgb(250, 134, 188);
opacity: 0.40;
z-index: 1
}
.header-content {
z-index: 2;
display: flex;
flex-wrap: wrap;
justify-content: center;
overflow: hidden;
}
.header-content h1 {
font-size: 50px;
color: rgb(255, 255, 255);
font-family: Alfa Slab One;
letter-spacing: 10px;
text-transform: uppercase;
-webkit-text-fill-color: transparent;
-webkit-text-stroke-width: 2px;
}
.header-content h3 {
color: rgb(247, 45, 146);
}
<header class="v-header container">
<div class="fullscreen-img-wrap">
<img src="giphy.gif" alt="audio waves">
</div>
<div class="header-overlay"></div>
<div class="header-content">
<h1 class="display-4">20Somethingandliving</h1>
<h3>Podcast</h3>
</div>
</header>
I think you want to break the word? because your h1 is missing the spaces, without telling the element to break the word it will overflow.
Solution:
word-break: break-word;// or break-all;
Working snippet:
* {
box-sizing: border-box;
font-family: Francois One;
}
body {
margin: 0;
font-family: Francois One;
font-size: 1rem;
line-height: 1.5;
overflow-x: hidden;
}
.v-header {
height: 100vh;
width: 100%;
display: flex;
align-items: center;
justify-content: center;
}
.container {
padding-left: 1rem;
padding-right: 1rem;
margin: auto;
text-align: center;
}
.fullscreen-img-wrap {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100vh;
overflow: hidden;
}
.fullscreen-img-wrap img {
min-width: 100%;
min-height: 100vh;
}
.header-overlay {
height: 100vh;
width: 100%;
position: absolute;
top: 0;
left: 0;
background: rgb(250, 134, 188);
opacity: 0.40;
z-index: 1
}
.header-content {
z-index: 2;
display: flex;
flex-wrap: wrap;
justify-content: center;
overflow: hidden;
}
.header-content h1 {
word-break: break-word;
font-size: 50px;
color: rgb(255, 255, 255);
font-family: Alfa Slab One;
letter-spacing: 10px;
text-transform: uppercase;
-webkit-text-fill-color: transparent;
-webkit-text-stroke-width: 2px;
}
.header-content h3 {
color: rgb(247, 45, 146);
}
<header class="v-header container">
<div class="fullscreen-img-wrap">
<img src="giphy.gif" alt="audio waves">
</div>
<div class="header-overlay"></div>
<div class="header-content">
<h1 class="display-4">20Somethingandliving</h1>
<h3>Podcast</h3>
</div>
</header>
Related
I am using Angular and trying to create a proper header. My content is overlapping on header as I scroll. When I tried to keep div-container class position as fixed still it gets distorted. I am trying to understand how can I keep header fixed so that the content does not overlap on header. The header code and app.component.html is as follows:
<div class="div-container">
<div class="frame">
<div class="frame-logo">
<img src="assets/Images/image21.svg" alt="image" class="image21" />
</div>
</div>
<span class="text203 body1Default">
<span class="text204">ML Platform</span>
</span>
</div>
CSS is:
.div-container {
min-height: 7vh;
}
.frame {
top: 0px;
left: 24px;
width: 688px;
display: flex;
position: absolute;
box-sizing: border-box;
align-items: center;
border-color: transparent;
}
.frame-logo {
margin: 0 64px 0 0;
display: flex;
padding: 8px;
position: relative;
box-sizing: border-box;
align-items: flex-start;
flex-shrink: 1;
border-color: transparent;
border-radius: 2px;
flex-direction: column;
background-color: var(--dl-color-white-whiteffffff60463);
}
.text203 {
top: 10px;
left: 78px;
color: var(--dl-color-blue-blue600dellblue0672cb347f1);
height: auto;
position: absolute;
align-self: auto;
text-align: left;
line-height: 36px;
text-decoration: none;
}
.text204 {
color: rgba(6, 114, 203, 1);
height: auto;
align-self: auto;
font-style: normal;
text-align: left;
font-weight: 300px;
font-stretch: normal;
text-decoration: none;
}
.body1Default {
font-size: 24px;
font-style: normal;
font-family: Roboto;
font-weight: 300px;
font-stretch: normal;
}
.image21 {
width: 201px;
height: 40px;
position: relative;
object-fit: cover;
border-color: transparent;
}
app.component.html
<app-header></app-header>
<div>
<router-outlet></router-outlet>
</div>
<app-footer></app-footer>
Currently the text headings which are inside a flexbox (the three divs) are not aligning with the main headings on the rest of the page.
See Image Here
The issue appears to only take place with the character length of the text headings inside the flexbox of three divs are not the same.
See Image of Alignment when character length is the same
I've unsuccessfully tried css alignments, but they do not appear to have an effect. My desired outcome for the three divs is something like this:
See successful reference alignment example
The code is here:
* {
margin: 0;
padding: 0;
box-sizing: border-box;
max-width: 100vw;
list-style: none;
scroll-behavior: smooth;
}
body {
height: 100%;
margin: 0;
background-color: white;
font-family: Poppins;
min-height: 100vh;
}
a {
color: black;
}
/* ----------------------------------------------------------Landing Page -------------------------------------*/
.full-height-grow {
height: 100%;
display: flex;
flex-direction: column;
}
section {
display: flex;
height: 100vh;
width: auto;
max-width: 80vw;
min-width: 75vw;
justify-content: center;
align-items: center;
margin: 0 auto;
}
.about-container {
padding-top: 100px;
height: 100vh;
width: 90vw;
max-width: 90vw;
display: flex;
flex-direction: column;
align-items: center;
text-align: center;
}
.about-img {
border-radius: 50%;
height: calc(80px + 40%);
width: auto;
}
.about-h1 {
font-family: 'Poppins', sans-serif;
color: rgb(255, 42, 95);
margin-top: 30px;
margin-right: -30px;
margin-left: -30px;
font-size:calc(12px + 0.8vw) ;
}
.about-h2 {
font-family: 'Poppins', sans-serif;
color: rgb(17, 17, 17);
margin-right: -30px;
margin-left: -30px;
font-size:calc(15px + 2vw) ;
font-weight: 500;
opacity: 0.9;
}
.about-desc {
font-family: Lora;
font-size:calc(10px + 1.2vw);
line-height: 1.8;
color: #888888;
text-align: center;
margin-left: 25vw;
margin-right: 25vw;
overflow:hidden;
z-index: 2;
width: auto;
}
.about-tasks-container {
align-self: center;
background-color: blanchedalmond;
max-width: 80vw;
width: 80vw;
display: flex;
justify-content: space-evenly;
text-align: center;
flex-direction: row;
flex-grow: 1;
}
.about-task-heading {
font-size: 80px;
}
.about-tasks-resources {
}
.about-tasks-learning {
}
<section class="about-section">
<div class="about-container" id="about">
<h2 class="about-h1"> ABOUT</h2>
<h3 class="about-h2">More About Me</h3>
<div class="about-tasks-container">
<div class="about-tasks-tutorials">
<h1 class="about-task-heading">Example</h1>
</div>
<div class="about-tasks-resources" >
<h1 class="about-task-heading">Exampler</h1>
</div>
<div class="about-tasks-learning">
<h1 class="about-task-heading">Examplers</h1>
</div>
</div>
</div>
</div>
</section>
(JSFiddle : https://jsfiddle.net/2cL5h4m6/9/)
Try this code
Idk if this is what you wanted but you can try it and you can see if it was the thing you looked for
* {
margin: 0;
padding: 0;
box-sizing: border-box;
max-width: 100vw;
list-style: none;
scroll-behavior: smooth;
}
body {
height: 100%;
margin: 0;
background-color: white;
font-family: Poppins;
min-height: 100vh;
}
a {
color: black;
}
/* ----------------------------------------------------------Landing Page -------------------------------------*/
.full-height-grow {
height: 100%;
display: flex;
flex-direction: column;
}
section {
display: flex;
height: 100vh;
width: auto;
max-width: 80vw;
min-width: 75vw;
justify-content: center;
align-items: center;
margin: 0 auto;
}
.about-container {
padding-top: 100px;
height: 100vh;
width: 90vw;
max-width: 90vw;
display: flex;
flex-direction: column;
align-items: center;
text-align: center;
}
.about-img {
border-radius: 50%;
height: calc(80px + 40%);
width: auto;
}
.about-h1 {
font-family: 'Poppins', sans-serif;
color: rgb(255, 42, 95);
margin-top: 30px;
margin-right: -30px;
margin-left: -30px;
font-size:calc(12px + 0.8vw) ;
}
.about-h2 {
font-family: 'Poppins', sans-serif;
color: rgb(17, 17, 17);
margin-right: -30px;
margin-left: -30px;
font-size:calc(15px + 2vw) ;
font-weight: 500;
opacity: 0.9;
}
.about-desc {
font-family: Lora;
font-size:calc(10px + 1.2vw);
line-height: 1.8;
color: #888888;
text-align: center;
margin-left: 25vw;
margin-right: 25vw;
overflow:hidden;
z-index: 2;
width: auto;
}
.about-tasks-container {
align-self: center;
background-color: blanchedalmond;
max-width: 100vw;
width: 100vw;
display: flex;
justify-content: space-evenly;
text-align: center;
flex-direction: row;
flex-grow: 0;
}
.about-task-heading {
font-size: 30px;
}
.about-tasks-resources {
}
.about-tasks-learning {
}```
I've written this code for a simple html page in which there are three sections. The top(first) and bottom(third) are full screen sections and the middle section has to be shown with both the top and bottom sections i.e., the upper half of the middle section with the top section and the bottom half with the third section.
I was able to show the first part correctly(when scroll position is at the top) but not the second part(which is when scroll position at the bottom).
Can anybody tell me how can I achieve that?
Full page: https://i.imgur.com/YDV1usM.png
When scroll position is at the top: https://i.imgur.com/Mngkqth.png
When scroll position is at the bottom: https://i.imgur.com/wugOxCY.png
* {
font-family: monospace;
}
h2 {
font-size: 100px;
font-family: monospace;
}
.section-1, .section-3 {
height: 100vh;
display: flex;
align-items: center;
justify-content: center;
}
.section-2 h6 {
font-size: 18px;
position: relative;
margin: 80px 0 !important;
}
.section-2 p {
font-size: 20px;
position: relative;
}
.section-2 {
text-align: center;
margin-top: -145px;
}
.section-2 h6:after {
content: '';
position: absolute;
height: 60px;
width: 1px;
background: #000;
left: 50%;
top: 30px;
}
<div class="section-1">
<h2>SECTION 1</h2>
</div>
<div class="section-2">
<h6>Scroll</h6>
<p>Studio Liana Lalush</p>
</div>
<div class="section-3">
<h2>SECTION 3</h2>
</div>
Are you expecting like this:
Note: check out my answer in full screen mode
Demo:
* {
font-family: monospace;
}
h2 {
font-size: 100px;
font-family: monospace;
}
.section-1,
.section-3 {
height: 100vh;
display: flex;
align-items: center;
justify-content: center;
}
.section-2 h6 {
font-size: 18px;
position: relative;
margin: 70px 0 !important;
}
.section-2 p {
font-size: 20px;
position: relative;
}
.section-2 {
text-align: center;
position: absolute;
top: 98%;
left: 50%;
transform: translate(-50%, -50%);
}
.section-2 h6:after {
content: '';
position: absolute;
height: 60px;
width: 1px;
background: #000;
left: 50%;
top: 25px;
}
<div class="section-1">
<h2>SECTION 1</h2>
</div>
<div class="section-2">
<h6>Scroll</h6>
<p>Studio Liana Lalush</p>
</div>
<div class="section-3">
<h2>SECTION 3</h2>
</div>
Try with this code. You only need to change in css code.
* {
font-family: monospace;
}
h2 {
font-size: 100px;
font-family: monospace;
}
.section-1 {
height: 100vh;
display: flex;
align-items: center;
justify-content: center;
}
.section-3{
height: 90vh;
display: flex;
align-items: center;
justify-content: center;
}
.section-2 h6 {
font-size: 18px;
position: relative;
margin: 80px 0 !important;
}
.section-2 p {
font-size: 20px;
position: relative;
}
.section-2 {
text-align: center;
margin-top: -145px;
}
.section-2 h6:after {
content: '';
position: absolute;
height: 60px;
width: 1px;
background: #000;
left: 50%;
top: 30px;
}
I don't understand why in this setup the padding-top is various times bigger than the padding-bottom. Tried tweaking stuff around to find the culprit property but so far nothing. I did notice, that I accidentally left a " after the spans, the issue was gone, but not sure how that relates.
https://jsfiddle.net/3n0yuzs3/1/
body
{
font-family: sans-serif;
}
#window
{
background-color: black;
color: white;
display: flex;
flex-direction: column;
opacity: 1;
left: 50%;
bottom: 0px;
position: fixed;
width: auto;
height: auto;
min-width: 600px;
min-height: auto;
max-width: 80vw;
max-height: 80vh;
transform: translateX(-50%);
outline: 0px;
cursor: default;
z-index: 5000002;
zoom: 1;
}
#container
{
overflow-y: auto;
overflow-x: hidden;
border: none;
outline: 0;
margin: 0;
flex-grow: 1;
}
#content
{
font-size: 22px;
text-align: center;
overflow-wrap: break-word;
padding-top: 1.6em;
padding-bottom: 1.6em;
padding-left: 1.6em;
padding-right: 1.6em;
}
.snack_msg
{
padding-right: 200px;
float:left;
}
.snack_btn
{
color:#5fce49;
text-transform: uppercase;
letter-spacing:3px;
cursor:pointer;
float:right;
}
<div id='window'>
<div id='container'>
<div id='content'>
<span class='snack_msg'>New message arrived</span>
<span class='snack_btn' onclick='open_snack_message()'>open</span>
</div>
</div>
</div>
The issue is with floating elements and not padding. As you can see below, you have equal padding in all the sizes :
And if you check well you will see also that you have a height equal to 0 because you have floating element and since the parent is not floating it will collapse (which means no height). To fix this you need to add oveflow:auto to #content.
body {
font-family: sans-serif;
}
#window {
background-color: black;
color: white;
display: flex;
flex-direction: column;
opacity: 1;
left: 50%;
bottom: 0px;
position: fixed;
width: auto;
height: auto;
min-width: 600px;
min-height: auto;
max-width: 80vw;
max-height: 80vh;
transform: translateX(-50%);
outline: 0px;
cursor: default;
z-index: 5000002;
zoom: 1;
}
#container {
overflow-y: auto;
overflow-x: hidden;
border: none;
outline: 0;
margin: 0;
flex-grow: 1;
}
#content {
font-size: 22px;
text-align: center;
overflow-wrap: break-word;
padding-top: 1.6em;
padding-bottom: 1.6em;
padding-left: 1.6em;
padding-right: 1.6em;
overflow: auto;
}
.snack_msg {
padding-right: 200px;
float: left;
}
.snack_btn {
color: #5fce49;
text-transform: uppercase;
letter-spacing: 3px;
cursor: pointer;
float: right;
}
<div id='window'>
<div id='container'>
<div id='content'>
<span class='snack_msg'>New message arrived</span>
<span class='snack_btn' onclick='open_snack_message()'>open</span>
</div>
</div>
</div>
Here is some usefull questions where you can gather more information and more ways to prevent this behavior:
How do you keep parents of floated elements from collapsing?
Why does 'overflow: auto' clear floats? And why are clear floats needed?
I want to create this homepage for my site which only accepts add-ons of html/css without retouching any other rule.
Only achieved making the blocks themselves but no clue on how to put images behind the buttons,center everything up and make it responsive...
Any tip?
Homepage intended
page link: www.lluisballbe.smugmug.com
Code used already is here:
html,
body {
height: 100%;
width: 100%;
margin: 0;
}
body {
display: flex;
flex-direction: column;
}
h1 {
margin: 0;
}
a {
display: inline-block;
}
#business-top {
display: flex;
flex: 1;
width: 100%;
align-items: center;
justify-content: center;
text-align: center;
background:turquoise;
}
#business-button {
height: 3em;
width: 12em;
background-color: #2B2A2A;
border: .2em solid #ff7600;
border-radius: 1.8em;
margin: auto;
}
#logo-separator {
text-align: center;
}
.separator {
display: block;
position: relative;
padding: 0;
height: 0;
width: 100%;
max-height: 0;
font-size: 1px;
line-height: 0;
flex: 0;
border-top: 1px solid #ff7600;
border-bottom: 1px solid #ff7600;
}
#logo {
margin: auto;
max-width: 150px;
display: inline-block;
overflow: hidden;
margin: -75px;
position: absolute;
z-index:1;
}
#photography-bottom {
display: flex;
flex: 1;
width: 100%;
align-items: center;
justify-content: center;
background:gray;
}
#photography-button {
height: 3em;
width: 12em;
background-color: #2B2A2A;
border: .2em solid #ff7600;
border-radius: 1.8em;
margin: auto;
}
h1 {
color: #ff7600;
text-align: center;
font-size: 1.4em;
vertical-align: middle;
line-height: 2.2em
}
#business-top,
#photography-bottom {
pointer-events: none;
position: relative;
transition: 1s;
min-height: 200px;
}
#business-top a,
#photography-bottom a {
pointer-events: auto;
}
#business-top:hover,
#photography-bottom:hover {
flex: 3;
}
#business-top a:hover:before,
#photography-bottom a:hover:before {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
}
<div id="business-top">
<a href="www.lluisballbe.smugmug.com">
<div id="business-button">
<h1>BUSINESS</h1>
</div>
</a>
</div>
<div id="logo-separator">
<div class="separator"></div>
<div id="logo"><img src="https://lluisballbe.smugmug.com/Assets-for-website/i-CsMnM3R/0/Th/800x800-round-Th.png"> </div>
</div>
<div id="photography-bottom">
<a href="www.lluisballbe.smugmug.com">
<div id="photography-button">
<h1>PHOTOGRAPHY</h1>
</div>
</a>
</div>
Images to be used (each should cover 50%, can resize them and change pixel size if needed):
https://dl.dropboxusercontent.com/u/54898895/Public.rar
[Top Image][3]
[Bottom image][4]
I'd do it this way:
Add height: 50vh; to #business-top and #photography-bottom for both outter container.
Give your containers your custom background-images: background-image: url('url to image');
Make sure the images have background-size: cover;
Add your #logo-separator with position:absolute;
and top: calc( 50% - (height_of_sperator)px;