The issue is the header: I need it to seem to be fixed on the fixed section and still be clickable.
When the first section scrolls over the header, it should cover the header.
I can move or change the header however I want:
<a href="#" class="header">
THIS IS THE HEADER
<span style="font-size: 12px;">(you can hover me)</span><br>
<span style="font-size: 14px; font-style: italic; letter-spacing: 0.05em;">which should be <br> OVER "invisible section" AND "fixed section" <br> BUT UNDER "first section", <br>WHILE maintaining fixed position</span>
</a>
and while I could add the header to the invisible section, I cannot change the overall structure of the sections:
<div class="section section-fixed">
fixed section underneath "invisible section"
</div>
<div class="wrapper">
<div class="section section-invisible">
<h2>invisible section</h2>
</div>
<div class="section section-first">
first section
</div>
</div>
I tried adding the header to the invisible section and while this works in keeping the header clickable, I cannot make it seem to be fixed the same as the fixed section.
I realise describing it might be confusing so here are some accompanying images and please check the FIDDLE
#import url("https://fonts.googleapis.com/css2?family=Baloo+Da+2&display=swap");
html {
box-sizing: border-box;
}
*, *:before, *:after {
box-sizing: inherit;
}
html, body {
margin: 0;
padding: 0;
}
body {
font-size: 16px;
font-family: 'Baloo Da 2', cursive;
}
.header {
background: floralwhite;
display: inline-block;
padding: 10px;
position: fixed;
z-index: 3;
left: 30px;
top: 30px;
color: inherit;
text-decoration: none;
line-height: 1.2;
box-shadow: 0 0 0 rgba(0, 0, 0, 0.5);
transition: all .5s ease;
}
.header:hover {
box-shadow: 2px 3px 10px rgba(0, 0, 0, 0.5);
background-color: pink;
}
.wrapper {
border: 2px solid red;
z-index: 2;
position: relative;
}
.section {
padding: 20px;
display: flex;
align-items: center;
justify-content: center;
height: 100vh;
}
.section-fixed {
background: gray;
position: fixed;
top: 0;
left: 0;
width: 100%;
z-index: 1;
}
.section-invisible {
align-items: flex-end;
padding: 0;
}
.section-invisible h2 {
background: goldenrod;
padding: 50px;
margin: 0;
width: 100%;
text-align: center;
}
.section-first {
background: darkslateblue;
color: white;
}
<a href="#" class="header">
THIS IS THE HEADER
<span style="font-size: 12px;">(you can hover me)</span><br>
<span style="font-size: 14px; font-style: italic; letter-spacing: 0.05em;">which should be <br> OVER "invisible section" AND "fixed section" <br> BUT UNDER "first section", <br>WHILE maintaining fixed position</span>
</a>
<div class="section section-fixed">
fixed section underneath "invisible section"
</div>
<div class="wrapper">
<div class="section section-invisible">
<h2>invisible section</h2>
</div>
<div class="section section-first">
first section
</div>
</div>
initial:
after scroll:
Update your z-index like below. The most important is to not set any z-index to wrapper:
#import url("https://fonts.googleapis.com/css2?family=Baloo+Da+2&display=swap");
html {
box-sizing: border-box;
}
*,
*:before,
*:after {
box-sizing: inherit;
}
html,
body {
margin: 0;
padding: 0;
}
body {
font-size: 16px;
font-family: 'Baloo Da 2', cursive;
}
.header {
background: floralwhite;
padding: 10px;
position: fixed;
z-index: 2; /* here */
left: 30px;
top: 30px;
color: inherit;
text-decoration: none;
line-height: 1.2;
box-shadow: 0 0 0 rgba(0, 0, 0, 0.5);
transition: all .5s ease;
}
.header:hover {
box-shadow: 2px 3px 10px rgba(0, 0, 0, 0.5);
background-color: pink;
}
.wrapper {
border: 2px solid red;
position: relative;
}
.section {
padding: 20px;
display: flex;
align-items: center;
justify-content: center;
height: 100vh;
}
.section-fixed {
background: gray;
position: fixed;
top: 0;
left: 0;
width: 100%;
z-index: 1; /* here */
}
.section-invisible {
align-items: flex-end;
padding: 0;
position: relative;
z-index: 1; /* here */
}
.section-invisible h2 {
background: goldenrod;
padding: 50px;
margin: 0;
width: 100%;
text-align: center;
}
.section-first {
background: darkslateblue;
color: white;
position: relative;
z-index: 2; /* here */
}
<a href="#" class="header">
THIS IS THE HEADER
<span style="font-size: 12px;">(you can hover me)</span><br>
<span style="font-size: 14px; font-style: italic; letter-spacing: 0.05em;">which should be <br> OVER "invisible section" AND "fixed section" <br> BUT UNDER "first section", <br>WHILE maintaining fixed position</span>
</a>
<div class="section section-fixed">
fixed section underneath "invisible section"
</div>
<div class="wrapper">
<div class="section section-invisible">
<h2>invisible section</h2>
</div>
<div class="section section-first">
first section
</div>
</div>
Related: Why can't an element with a z-index value cover its child?
Related
I have a which contains a gridlayout with some cells. When the div is shown or hidden it should scale gradually over time. Currently when showing, the div is initially sized to fit the contents and then scales. When hidden it is immediately hidden unless padding is set. Then it is immediately resized to the size of the padding.
Example is shown below. How to adapt the styling in such that the div resizes smoothly and text stays in place (clips and does not wrap)
function toggle() {
if (document.getElementsByClassName("ovdInfobox")[0].classList.contains("ovdInfobox--visible")) {
document.getElementsByClassName("ovdInfobox")[0].classList.remove("ovdInfobox--visible")
console.log('remove');
} else {
document.getElementsByClassName("ovdInfobox")[0].classList.add("ovdInfobox--visible")
console.log('add');
}
}
.ovdInfobox {
display: grid;
grid: 40px auto / auto auto;
z-index: 1;
position: absolute;
top: 50px;
width: 0;
height: 0;
min-width: 0;
min-height: 0;
overflow: hidden;
padding: 0;
border: 0;
background: rgba(255, 255, 255, 0.98);
border-radius: 4px;
font-family: inherit;
font-size: inherit;
line-height: inherit;
transition: all 4.2s ease-in-out;
background: green;
}
.ovdInfobox--visible {
width: unset;
height: unset;
min-width: 300px;
border: 1px solid #d1d1d1;
/* padding: 15px 15px 15px 15px;*/
}
.ovdInfobox__header {
grid-column-start: span 2;
color: #c20063;
font-size: 18px;
font-weight: normal;
}
.ovdInfobox__label {
font-weight: bold;
}
.ovdInfobox__data {}
<div>
<button onclick="toggle()">
Click Me!
</button>
<div class="ovdInfobox ovdInfobox--visible" onCLick="toggle()">
<div class="ovdInfobox__header">Details</div>
<div class="ovdInfobox__label">
label
</div>
<div class="ovdInfobox__data">
data
</div>
<div class="ovdInfobox__label">
label
</div>
<div class="ovdInfobox__data">
data
</div>
</div>
</div>
New day, fresh start, fresh mind.
Changed class .ovdInfobox and .ovdInfobox--visible by replacing width, height, min-width and min-height by max-width and max-height. Resizing now works as expected.
function toggle() {
if (document.getElementsByClassName("ovdInfobox")[0].classList.contains("ovdInfobox--visible")) {
document.getElementsByClassName("ovdInfobox")[0].classList.remove("ovdInfobox--visible")
console.log('remove');
} else {
document.getElementsByClassName("ovdInfobox")[0].classList.add("ovdInfobox--visible")
console.log('add');
}
}
.ovdInfobox {
display: grid;
grid: 40px auto / auto auto;
column-gap:10px ;
row-gap: 5px;
z-index: 1;
position: absolute;
top: 50px;
max-width: 0;
max-height: 0;
overflow: hidden;
padding: 0;
border: 0;
background: rgba(255, 255, 255, 0.98);
border-radius: 4px;
font-family: inherit;
font-size: inherit;
line-height: inherit;
transition: all 4.2s ease-in-out;
background: green;
}
.ovdInfobox--visible {
max-width: 300px;
max-height: 200px;
border: 1px solid #d1d1d1;
padding: 15px 15px 15px 15px;
}
.ovdInfobox__header {
grid-column-start: span 2;
color: #c20063;
font-size: 18px;
font-weight: normal;
}
.ovdInfobox__label {
font-weight: bold;
}
.ovdInfobox__data {}
<div>
<button onclick="toggle()">
Click Me!
</button>
<div class="ovdInfobox ovdInfobox--visible" onCLick="toggle()">
<div class="ovdInfobox__header">Details</div>
<div class="ovdInfobox__label">
label
</div>
<div class="ovdInfobox__data">
data
</div>
<div class="ovdInfobox__label">
label
</div>
<div class="ovdInfobox__data">
data
</div>
</div>
</div>
I'm working on a website splash page which should show rows of same height. Each row has a title and further text items and one image.
The text and image items should align at the bottom of each row as shown on following screenshot
On Hover, the image should slide up to max height which fits into the row.
My question is:
Can I access the current value of 1fr from parent row grid-auto-rows: 1fr;to give the image on hover a max height?
This is how my code currently looks like:
html, body {margin:0; padding:0}
.jumbo {
width: 100%;
height: 100vh;
background: yellow;
display: grid;
grid-auto-rows: 1fr;
}
.jumbo__item {
position: relative;
box-shadow: 0px 1px 5px 0px rgba(0, 0, 0, 0.75);
font-size: 20vh;
padding: 0 0 0 10px;
#overflow: hidden;
}
.jumbo__rowtags{
position: absolute;
bottom: 0;
right: 0;
}
.jumbo__tag {
margin-right: 10px;
display: inline-block;
background: white;
vertical-align: bottom;
height: 30px;
padding: 0 10px;
font-size: 20px;
line-height: 30px;
}
.jumbo__tag-high{
height: 30px;
overflow: hidden;
background: none;
cursor: pointer;
}
.jumbo__tag-high:hover{
height: auto;
max-height: 200px;
}
.a {background: lightblue; }
.b {background: lightgreen}
.c {background: lightgrey}
<div class="jumbo">
<div class="jumbo__item a">
Dogs
</div>
<div class="jumbo__item b">
and
<section class="jumbo__rowtags">
<span class="jumbo__tag jumbo__tag-high"><img src="https://placeimg.com/350/200/nature"></span>
<span class="jumbo__tag">Hello</span>
<span class="jumbo__tag">World</span>
</section>
</div>
<div class="jumbo__item c">
cats
</div>
</div>
You can make the image and its container to be height:100% of the row then consider a transform animation
html, body {margin:0; padding:0}
.jumbo {
width: 100%;
height: 100vh;
background: yellow;
display: grid;
grid-auto-rows: 1fr;
}
.jumbo__item {
position: relative;
box-shadow: 0px 1px 5px 0px rgba(0, 0, 0, 0.75);
font-size: 20vh;
padding: 0 0 0 10px;
#overflow: hidden;
}
.jumbo__rowtags{
position: absolute;
bottom: 0;
right: 0;
top:0; /* added */
}
.jumbo__tag {
margin-right: 10px;
display: inline-block;
background: white;
vertical-align: bottom;
height: 30px;
padding: 0 10px;
font-size: 20px;
line-height: 30px;
}
.jumbo__tag-high{
height: 100%; /* added */
overflow: hidden;
background: none;
cursor: pointer;
}
.jumbo__tag-high img {
height:100%; /* added */
transform:translateY(calc(100% - 30px));
transition:1s all;
}
.jumbo__tag-high:hover img{
transform:translateY(0%);
}
.a {background: lightblue; }
.b {background: lightgreen}
.c {background: lightgrey}
<div class="jumbo">
<div class="jumbo__item a">
Dogs
</div>
<div class="jumbo__item b">
and
<section class="jumbo__rowtags">
<span class="jumbo__tag jumbo__tag-high"><img src="https://placeimg.com/350/200/nature"></span>
<span class="jumbo__tag">Hello</span>
<span class="jumbo__tag">World</span>
</section>
</div>
<div class="jumbo__item c">
cats
</div>
</div>
I'm creating an alphabet tracing/writing worksheet layout. It doesn't overflow correctly.
I tried duplicating the code sample with fewer letters so it doesn't overflow. The problem is some letters are longer than others so they would continue to overflow.
I expect the excess letters to move down and recreate the top/middle/bottom border.
.wrap {
position: relative;
width: 500px
}
.top {
border-top: 2px solid #000;
height: 30px
}
.center {
border-top: 1px dashed #000;
height: 30px
}
.letter {
position: absolute;
top: 11px;
font-size: 84px;
padding-bottom: 30px
}
<div class="wrap">
<div class="top">
</div>
<div class="center">
</div>
<div class="top">
<div class="letter">A B C D E O P Q R S T U V W X Y Zs</div>
</div>
</div>
Edited to add snippet
It depends on the font-family since each one is unique in height and width. You'll get varying lengths for each letter if the font-family is serif or sans-serif type, but if it is a monospace type then all lengths for each letter is uniformly the same.
The following demo uses text-decoration: overline underline and an overlay with text-decoration: line-through dashed. There's two examples:
font-family: Arial (san-serif)
font-family: Consolas (monospace)
:root {
font: 500 9vw/1.2 Arial;
}
.alphabet {
position: relative;
height: 7rem;
max-width: 96%;
margin: 5vh 2vw;
}
.text {
position: relative;
margin: 0 auto;
width: 100%;
height: 1rem;
font-stretch: ultra-expanded
}
.line {
display: inline-block;
position: absolute;
background: transparent;
}
.edges {
z-index: 0;
top: .3rem;
left: 0;
text-decoration: overline underline rgba(255, 255, 128, 0.7);
}
.edges del {
color: transparent;
}
.middle {
z-index: 1;
top: 0;
left: 0;
word-break: break-word;
color: transparent;
text-decoration: line-through dashed rgba(0, 0, 0, 0.3);
}
h4 {
margin: 0 0 -3vw 0
}
.consolas {
font-family: Consolas;
font-size: 1rem;
line-height: 1.2;
}
.consolas h4 {
margin: 0 0 -2vh 0;
font-size: 1.1rem
}
.consolas .text {
height: 0.5rem;
}
.consolas .edges {
top: 0.2rem
}
<figure class='alphabet'>
<h4>Arial</h4>
<figcaption class='text'>
<mark class='line edges'>Aa Bb Cc Dd Ee Ff Gg Hh Ii Jj Kk Ll Mm Nn Oo Pp Qq Rr Ss Tt Uu Vv Ww Xx Yy Zz<del>XXXx</del></mark>
<mark class='line middle'>Aa Bb Cc Dd Ee Ff Gg Hh Ii Jj Kk Ll Mm Nn Oo Pp Qq Rr Ss Tt Uu Vv Ww Xx Yy ZzXXXx</mark>
</figcaption>
</figure>
<figure class='alphabet consolas'>
<h4>Consolas</h4>
<figcaption class='text'>
<mark class='line edges'>Aa Bb Cc Dd Ee Ff Gg Hh Ii Jj Kk Ll Mm Nn Oo Pp Qq Rr Ss Tt Uu Vv Ww Xx Yy Zz<del>XXXx</del></mark>
<mark class='line middle'>Aa Bb Cc Dd Ee Ff Gg Hh Ii Jj Kk Ll Mm Nn Oo Pp Qq Rr Ss Tt Uu Vv Ww Xx Yy ZzXXXx</mark>
</figcaption>
</figure>
I have a navbar with a few elements inside it and a button that escapes the navbar when i resize it. What CSS property should I style to keep the button in CSS to stop the button from escaping the navbar?
Attached is a JFiddle of an example of what happens:
https://jsfiddle.net/6Lx0hkfa/
.green-button {
font-size: 13px;
display: inline-block;
height: 50px;
width: 170px;
float: left;
margin-left: 235px;
padding: 6px 10px;
background-color: rgb(185, 233, 137);
color: rgb(43, 150, 190);
text-transform: uppercase;
border-radius: 0px;
border-width: 0px;
border-style: initial;
border-color: initial;
box-sizing: border-box;
}
<section id="header">
<div class="wrapper">
<div class="address">7542 Fay Ave Upstairs Suite, La Jolla, CA 92037</div>
<div class="phone">(858) 381-0740</div>
<div class="email">sdacneclinic#gmail.com</div>
<div class="social">
<a class="social-btn fb" href="http://facebook.com"></a>
</div>
<div class="social">
<a class="social-btn tw" href="http://twitter.com"></a>
</div>
<div class="social">
<a class="social-btn ig" href="http://instagram.com"></a>
</div>
<div class="social">
<a class="social-btn gp" href="https://plus.google.com"></a>
</div>
<a href="/contacts">
<button class="green-button">Book Consultation</button>
</a>
</div>
</section>
I don't know what you are trying to achieve, but this one worked for me:
.green-button {
position: absolute;
}
This is a case where I would use float for simplicity. Note that this requires to put the link element on top of the rest of the wrapper's contents within the markup, but it's the most direct solution.
.green-button-link {
float: left;
}
.green-button {
font-size: 13px;
display: inline-block;
height: 50px;
width: 170px;
margin-right: 20px;
padding: 6px 10px;
background-color: rgb(185, 233, 137);
color: rgb(43, 150, 190);
text-transform: uppercase;
border-radius: 0px;
border-width: 0px;
border-style: initial;
border-color: initial;
box-sizing: border-box;
}
<section id="header">
<div class="wrapper">
<a class="green-button-link" href="/contacts">
<button class="green-button">Book Consultation</button>
</a>
<div class="address">7542 Fay Ave Upstairs Suite, La Jolla, CA 92037</div>
<div class="phone">(858) 381-0740</div>
<div class="email">sdacneclinic#gmail.com</div>
<div class="social">
<a class="social-btn fb" href="http://facebook.com"></a>
</div>
<div class="social">
<a class="social-btn tw" href="http://twitter.com"></a>
</div>
<div class="social">
<a class="social-btn ig" href="http://instagram.com"></a>
</div>
<div class="social">
<a class="social-btn gp" href="https://plus.google.com"></a>
</div>
</div>
</section>
check the snippet if its what you want.i added description add to ones I added to your code.
* {
margin: 0;
padding: 0;
}
body {
background: url(img/hero_bg.jpg) repeat-y center center fixed;
background size: 100%;
}
#header {
background-color: #1d7cb6;
display: block;
/* position: relative; */
color: white;
width: 100%;
height: 50px;
}
.wrapper {
text-align: center;
margin: 0px auto;
font-family: 'Raleway';
background: white;
z-index: 500;
vertical-align: middle;/* add */
position: relative;/* add */
padding-right: 200px;
}
.address {
display: inline-block;
width: 240px;
float: left;
display: inline-block;
height: 100%;
font-size: 10px;
padding: 20px 18px;
}
.phone {
display: inline-block;
width: 100px;
float: left;
height: 100%;
font-size: 10px;
padding: 20px 18px;
}
.email {
width: 150px;
float: left;
display: inline-block;
height: 100%;
padding: 20px 18px;
font-size: 10px;
}
a.social-btn {
width: 20px;
height: 20px;
margin-top: 13px;
float: left;
}
a.social-btn.fb {
background: url("img/facebook#2x.png") 0% 0%/ 20px 20px no-repeat;
display: inline-block;
}
a.social-btn.tw {
background: url("img/twitter#2x.png") 0% 0% / 20px 20px no-repeat;
display: inline-block;
}
a.social-btn.ig {
background: url("img/instagram#2x.png") 0% 0% / 20px 20px no-repeat;
}
a.social-btn.gp {
background: url("img/google#2x.png") 0% 0% / 20px 20px no-repeat;
}
section {
width: 900px;
margin: 0 auto;
}
section#header .wrapper button.green-button {
text-decoration: none;
font-family: 'Raleway';
}
.green-button {
font-size: 13px;
display: inline-block;
height: 50px;
width: 170px;
/* float: left; */
right: 0;/* add */
position: absolute;/* add */
/* margin-left: 235px; */
padding: 6px 10px;
background-color: rgb(185, 233, 137);
color: rgb(43, 150, 190);
text-transform: uppercase;
border-radius: 0px;
border-width: 0px;
border-style: initial;
border-color: initial;
box-sizing: border-box;
}
<section id="header">
<div class="wrapper">
<div class="address">7542 Fay Ave Upstairs Suite, La Jolla, CA 92037</div>
<div class="phone">(858) 381-0740</div>
<div class="email">sdacneclinic#gmail.com</div>
<div class="social"><a class="social-btn fb" href="http://facebook.com"></a></div>
<div class="social"><a class="social-btn tw" href="http://twitter.com"></a></div>
<div class="social"><a class="social-btn ig" href="http://instagram.com"></a></div>
<div class="social"><a class="social-btn gp" href="https://plus.google.com"></a></div>
<button class="green-button">Book Consultation</button>
</div>
</section>
I want to crate a search bar similar to that of https://www.zomato.com/ Exactly the same layout.
I am able create a floating search box on top of my background image. Not sure how to join various input fields and button side by side. This is the css I have as of now.
.search {
background:rgba(0,0,0,0.6);
border: 2px solid #414141;
border-radius: 5px;
padding: 10px;
}
header {
text-align: center;
color: #fff;
background-attachment: scroll;
background-image: url(../img/header-bg.jpg);
background-position: center center;
background-repeat: none;
-webkit-background-size: cover;
-moz-background-size: cover;
background-size: cover;
-o-background-size: cover;
}
header .intro-text {
padding-top: 100px;
padding-bottom: 50px;
}
header .intro-text .intro-lead-in {
margin-bottom: 25px;
font-family: "Droid Serif","Helvetica Neue",Helvetica,Arial,sans-serif;
font-size: 22px;
font-style: italic;
line-height: 22px;
}
As for the HTML:
<body id="page-top" class="index">
<!-- I have a navbar here -->
<!-- Header -->
<header>
<div class="intro-text">
<div class="intro-lead-in">Welcome To Our Studio!</div>
<div class="intro-heading">It's Nice To Meet You</div>
</div>
</header>
</body>
this is a fiddle which containes the style of the bar. I think it may help you.Main interest css is:
.header-link {
float: left;
height: 60px;
margin: 0px 7px auto 0px;
}
.header-link a {
line-height: 62px;
color:#FFF;
}
.header-hiring-btn {
background-color: #CB202D;
padding: 7px 8px 6px;
border-radius: 3px;
text-align: center;
color: #FFF !important;
transition: all 0.15s ease-out 0s;
margin-right: 6px;
}
.header {
box-sizing: border-box;
height: 60px;
position: absolute;
width: 100%;
z-index: 7;
background: none repeat scroll 0% 0% rgba(45, 45, 45, 0.8) !important;
color:#FFF;
}
.wrapper {
padding-left: 10px;
padding-right: 10px;
margin-right: auto;
margin-left: auto;
box-sizing: border-box;
max-width: 1140px;
}
.col-s-16 {
width: 100%;
box-sizing: border-box;
}
.logo-header {
width: 134px;
}
.logo {
display: inline-block;
float: left;
text-align: center;
height:46px;
}
.logo img {
width: 130px;
margin-top: 15px;
margin-left: -4px;
vertical-align: middle;
border: 0px none;
}
.header-navigation {
float: right;
display: inline-block;
height: 60px;
}
.login-navigation {
float: left;
}
.header-link {
float: left;
height: 60px;
margin: 0px 7px auto 0px;
}
.header-link a {
line-height: 62px;
color:#FFF;
}
.header-hiring-btn {
background-color: #CB202D;
padding: 7px 8px 6px;
border-radius: 3px;
text-align: center;
color: #FFF !important;
transition: all 0.15s ease-out 0s;
margin-right: 6px;
}
<header class="header header--fixed " id="header">
<div class="wrapper">
<div class="">
<div class="col-s-16"> <a class="logo logo--header" href="https://www.zomato.com" title="">
<img src="https://bzmtcdn-a.akamaihd.net/images/logo/zlogo.png" alt="">
</a>
<section class="header-navigation" id="header-navigation">
<section class="login-navigation" id="login-navigation">
<div class="header-link"> <a class="header-hiring-btn" href="https://www.zomato.com/careers" target="_blank">We're Hiring!</a>
</div> <span class="header-link">
Log in with Facebook
</span>
<span class="header-link mr0">
Log in
</span>
</section>
</section>
<!-- end header-navigation -->
</div>
<!-- end col-s-16 -->
</div>
<!-- end row -->
</div>
<!-- end wrapping class -->
</header>
The code seems to be based on bootstrap.css rebuild. Hope it helps.