Can anyone tell me a solution to make the page not jump back to the top when this CSS driven popup box closes?
At the moment the popup opens in the correct place but when you close it, the page jumps back to the top.
body {
font-family: Arial, sans-serif;
background-color:#721213;
background-size: cover;
}
h1 {
text-align: center;
font-family: Tahoma, Arial, sans-serif;
color: orange;
margin: 100px 0;
}
.box {
width: 20%;
margin: 0 auto;
background: rgba(255,255,255,0.2);
padding: 35px;
border: 2px solid #fff;
border-radius: 20px/50px;
background-clip: padding-box;
text-align: center;
}
.button {
font-size: 1em;
padding: 10px;
color: #fff;
border: 2px solid orange;
border-radius: 20px/50px;
text-decoration: none;
cursor: pointer;
transition: all 0.3s ease-out;
}
.button:hover {
background: orange;
}
.overlay {
position: fixed;
top: 0;
bottom: 0;
left: 0;
right: 0;
background: rgba(0, 0, 0, 0.7);
transition: opacity 500ms;
visibility: hidden;
opacity: 0;
}
.overlay:target {
visibility: visible;
opacity: 1;
}
.popup {
margin: 70px auto;
padding: 20px;
background: #fff;
border-radius: 5px;
width: 40%;
position: relative;
transition: all 5s ease-in-out;
min-height:500px;
}
.popup h2 {
margin-top: 0;
color: #333;
font-family: Tahoma, Arial, sans-serif;
}
.popup .close {
position: absolute;
top: 20px;
right: 30px;
transition: all 200ms;
font-size: 30px;
font-weight: bold;
text-decoration: none;
color: #333;
}
.popup .close:hover {
color: orange;
}
.popup .content {
max-height: 30%;
overflow: auto;
}
.iframe {
width:95%;
display:block;
margin:0px auto 0px auto;
height:500px;
}
<div style="width:50%; margin:20px auto; background-color:#000; height:1000px;"></div>
<div style="width:50%; margin:20px auto; height:500; padding:200px 50px 20px 50px;">
Let me Pop up
<div id="popup1" class="overlay">
<div class="popup">
<h2>Here i am</h2>
<a class="close" href="#">×</a>
<div class="content">
<iframe class="iframe" src="http://www.impressdesign.com.au/clients/IMP/test.pdf"></iframe>
</div>
</div>
</div>
</div>
Weave: http://kodeweave.sourceforge.net/editor/#3cfa8a8181c0ffdc30103eb2bc19d9b3
Weave: (properly use a hash on an href)
http://kodeweave.sourceforge.net/editor/#3a84a44278b04eea7b5d0f067ba22427
Stop using href="#" and start using href="javascript:void(0)" instead.
The reason it jumps to the top is because when you use a hash in a href attribute it directs to an ID if none is specified it goes to the top by default. Unless you use e.preventDefault() using a click event in JS.
Because you're using :target This can easily be fixed by targeting a new ID.
So change this...
Let me Pop up
<a class="close">×</a>
to this...
Let me Pop up
<a class="close" href="#showpopup">×</a>
and it's fixed!
NOTE: You can do the same effect using a input[type=checkbox] instead of :target: http://kodeweave.sourceforge.net/editor/#8d7733f82faf240e0edcb6739c5d1a1a
A few key notes:
margin:0px auto 0px auto;
Values of 0 shouldn't have units specified.
Also it's bad practice to add CSS to your HTML element
<div style="width:50%; margin:20px auto; background-color:#000; height:1000px;"></div>
<!--
Instead put your CSS in your style sheet as a class;
that way it's easier to manage, maintain and get help if needed.
-->
<div class="box"></div>
Here is an example of one way on how to properly use a hash tag on a href attribute.
body {
padding: 1em;
width: 50%;
margin: 0 auto;
text-align: center;
}
.left {
text-align: left;
}
<ul class="left">
<li>
Lorem.
</li>
<li>
Ispum!
</li>
<li>
Dolor!
</li>
<li>
Sit!
</li>
<li>
Amet!
</li>
</ul>
<p id="lorem" class="left">
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Iste distinctio omnis a nihil, quisquam nisi similique facere, reprehenderit sint nostrum. Ipsa quibusdam, adipisci laudantium nam voluptatum quasi animi placeat eveniet.
</p>
<p id="ipsum" class="left">
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Vel tempora quasi, maiores debitis cupiditate laboriosam alias placeat temporibus veritatis. Quisquam, debitis dolorem saepe enim maiores, ex numquam corporis atque magnam.
</p>
<p id="dolor" class="left">
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ratione architecto quia officiis, amet. Eaque, et quia ducimus possimus rem suscipit, maxime, porro mollitia, corporis sequi magnam debitis. Expedita iure, maiores.
</p>
<p id="sit" class="left">
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Sunt ipsum vitae quasi, id reiciendis iure qui veritatis voluptatibus omnis libero ea, labore voluptate maxime, ducimus tenetur, deleniti. Rem, consequatur, accusantium.
</p>
<p id="amet" class="left">
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Dolorum maiores saepe sunt commodi soluta minus ad. Facilis magnam, distinctio voluptatibus ratione iste, laboriosam hic perspiciatis molestiae repellat accusamus tempora cumque!
</p>
Go to top
it happens because your button for closing is a element and href="#" change it to div element instead of a
EDIT :
i dont know why i got arrow down/point down but
i will explain it easier for you
Your CODE :
<div class="popup">
<h2>Here i am</h2>
<a class="close" href="#">×</a>
</div>
The what i suggest :
<div class="popup" id="popup">
<h2>Here i am</h2>
<div onClick="document.getElementById('popup').style.display='none';">X</div>
</div>
we added id="popup" to (div.popup) element, then we replaced " element" close button with
Related
I have found an awesome HTML and CSS stacked card article in CSS-tricks. In that demo there is no image, but I want to add an image on the right side of the card in the below code, attached an image for reference. I have tried with all my knowledge but I couldn't make it look like in the image I have attached. Could anyone please help me?
.wrapper {
margin-top: 100px;
padding-top: 150px;
padding-bottom: 1000px;
max-width: 700px;
margin: 0 auto;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
}
.card1, .card2, .card3, .card4, .card5, .card6, .card7 {
top: 30px;
position: sticky;
border: 1px solid #ccc;
box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.1);
background-color: white;
color: #333;
padding: 40px;
border-radius: 10px;
margin-bottom: 20px;
height: 380px;
}
.card1:nth-child(1n) {
top: 20px;
}
.card2:nth-child(2n) {
top: 40px;
}
.card3:nth-child(3n) {
top: 60px;
}
.card4:nth-child(4n) {
top: 80px;
}
.card5:nth-child(5n) {
top: 100px;
}
.card6:nth-child(6n) {
top: 120px;
}
.card7:nth-child(7n) {
top: 140px;
}
.card:nth-child(8n) {
top: 160px;
}
.card1{
background-color: #CAC5F5;
}
.card2{
background-color: #C0FFD6
}
.card3{
background-color: #FCF4B0
}
.card4{
background-color: #FFB1B0
}
.card5{
background-color: #8AC9FF
}
.classname {
background-color:#44c767;
text-indent:0;
display:inline-block;
color:#ffffff;
font-size:15px;
font-style:normal;
height:50px;
line-height:50px;
width:140px;
text-decoration:none;
text-align:center;
}.classname:hover {
background-color:#5cbf2a;
}.classname:active {
position:relative;
top:1px;
}
<div class="wrapper">
<div class="card1">
<h2><span>Project #1</span>Title of the Project</h2>
<p>Lorem ipsum dolor sit, amet consectetur adipisicing elit. Harum, perspiciatis blanditiis accusamus commodi consectetur id tempora rem iure eligendi quos eos et autem ratione exercitationem earum laborum ad a sequi!</p>
Know More
</div>
<div class="card2">
<h2><span>Project #2</span>Title of the Project</h2>
<p>Lorem ipsum dolor sit, amet consectetur adipisicing elit. Harum, perspiciatis blanditiis accusamus commodi consectetur id tempora rem iure eligendi quos eos et autem ratione exercitationem earum laborum ad a sequi!</p>
</div>
<div class="card3">
<h2><span>Project #3</span>Title of the Project</h2>
<p>Lorem ipsum dolor sit, amet consectetur adipisicing elit. Harum, perspiciatis blanditiis accusamus commodi consectetur id tempora rem iure eligendi quos eos et autem ratione exercitationem earum laborum ad a sequi!</p>
</div>
<div class="card4">
<h2><span>Project #4</span>Title of the Project</h2>
<p>Lorem ipsum dolor sit, amet consectetur adipisicing elit. Harum, perspiciatis blanditiis accusamus commodi consectetur id tempora rem iure eligendi quos eos et autem ratione exercitationem earum laborum ad a sequi!</p>
</div>
<div class="card5">
<h2><span>Project #5</span>Title of the Project</h2>
<p>Lorem ipsum dolor sit, amet consectetur adipisicing elit. Harum, perspiciatis blanditiis accusamus commodi consectetur id tempora rem iure eligendi quos eos et autem ratione exercitationem earum laborum ad a sequi!</p>
</div>
</div>
I made two DIV elements .image and .left (You will find them at the bottom of CSS) that position the content and the photo
.wrapper {
margin-top: 100px;
padding-top: 150px;
padding-bottom: 1000px;
max-width: 700px;
margin: 0 auto;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
}
.card1,
.card2,
.card3,
.card4,
.card5,
.card6,
.card7 {
top: 30px;
position: sticky;
border: 1px solid #ccc;
box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.1);
background-color: white;
color: #333;
padding: 40px;
border-radius: 10px;
margin-bottom: 20px;
height: 380px;
}
.card1:nth-child(1n) {
top: 20px;
}
.card2:nth-child(2n) {
top: 40px;
}
.card3:nth-child(3n) {
top: 60px;
}
.card4:nth-child(4n) {
top: 80px;
}
.card5:nth-child(5n) {
top: 100px;
}
.card6:nth-child(6n) {
top: 120px;
}
.card7:nth-child(7n) {
top: 140px;
}
.card:nth-child(8n) {
top: 160px;
}
.card1 {
background-color: #CAC5F5;
}
.card2 {
background-color: #C0FFD6
}
.card3 {
background-color: #FCF4B0
}
.card4 {
background-color: #FFB1B0
}
.card5 {
background-color: #8AC9FF
}
.classname {
background-color: #44c767;
text-indent: 0;
display: inline-block;
color: #ffffff;
font-size: 15px;
font-style: normal;
height: 50px;
line-height: 50px;
width: 140px;
text-decoration: none;
text-align: center;
}
.classname:hover {
background-color: #5cbf2a;
}
.classname:active {
position: relative;
top: 1px;
}
.left {
position: relative;
margin-right: 50%;
}
.image {
position: absolute;
top: 0px;
right: 0px;
bottom: 0px;
left: 50%;
overflow: hidden;
border-radius: 0 10px 10px 0;
}
<div class="wrapper">
<div class="card1">
<div class="left">
<h2><span>Project #1</span>Title of the Project</h2>
<p>Lorem ipsum dolor sit, amet consectetur adipisicing elit. Harum, perspiciatis blanditiis accusamus
commodi consectetur id tempora rem iure eligendi quos eos et autem ratione exercitationem earum
laborum
ad a sequi!</p>
Know More
</div>
<div class="image">
<img src="https://blog.54ka.org/wp-content/uploads/2020/06/fairy-tales-luminance-fashion-photography_by_54ka.jpg">
</div>
</div>
<div class="card2">
<div class="left">
<h2><span>Project #2</span>Title of the Project</h2>
<p>Lorem ipsum dolor sit, amet consectetur adipisicing elit. Harum, perspiciatis blanditiis accusamus
commodi consectetur id tempora rem iure eligendi quos eos et autem ratione exercitationem earum
laborum
ad a sequi!</p>
</div>
<div class="image">
<img src="https://blog.54ka.org/wp-content/uploads/2020/06/fairy-tales-luminance-fashion-photography_by_54ka.jpg">
</div>
</div>
<div class="card3">
<div class="left">
<h2><span>Project #3</span>Title of the Project</h2>
<p>Lorem ipsum dolor sit, amet consectetur adipisicing elit. Harum, perspiciatis blanditiis accusamus
commodi consectetur id tempora rem iure eligendi quos eos et autem ratione exercitationem earum
laborum
ad a sequi!</p>
</div>
<div class="image">
<img src="https://blog.54ka.org/wp-content/uploads/2020/06/fairy-tales-luminance-fashion-photography_by_54ka.jpg">
</div>
</div>
<div class="card4">
<div class="left">
<h2><span>Project #4</span>Title of the Project</h2>
<p>Lorem ipsum dolor sit, amet consectetur adipisicing elit. Harum, perspiciatis blanditiis accusamus
commodi consectetur id tempora rem iure eligendi quos eos et autem ratione exercitationem earum
laborum
ad a sequi!</p>
</div>
<div class="image">
<img src="https://blog.54ka.org/wp-content/uploads/2020/06/fairy-tales-luminance-fashion-photography_by_54ka.jpg">
</div>
</div>
<div class="card5">
<div class="left">
<h2><span>Project #5</span>Title of the Project</h2>
<p>Lorem ipsum dolor sit, amet consectetur adipisicing elit. Harum, perspiciatis blanditiis accusamus
commodi consectetur id tempora rem iure eligendi quos eos et autem ratione exercitationem earum
laborum
ad a sequi!</p>
</div>
<div class="image">
<img src="https://blog.54ka.org/wp-content/uploads/2020/06/fairy-tales-luminance-fashion-photography_by_54ka.jpg">
</div>
</div>
</div>
.wrapper {
margin-top: 100px;
padding-top: 150px;
padding-bottom: 1000px;
max-width: 700px;
margin: 0 auto;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
}
.card1, .card2, .card3, .card4, .card5, .card6, .card7 {
top: 30px;
position: sticky;
border: 1px solid #ccc;
box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.1);
background-color: white;
color: #333;
padding: 40px;
border-radius: 10px;
margin-bottom: 20px;
height: 380px;
}
.card1:nth-child(1n) {
top: 20px;
}
.card2:nth-child(2n) {
top: 40px;
}
.card3:nth-child(3n) {
top: 60px;
}
.card4:nth-child(4n) {
top: 80px;
}
.card5:nth-child(5n) {
top: 100px;
}
.card6:nth-child(6n) {
top: 120px;
}
.card7:nth-child(7n) {
top: 140px;
}
.card:nth-child(8n) {
top: 160px;
}
.card1{
background-color: #CAC5F5;
}
.card2{
background-color: #C0FFD6
}
.card3{
background-color: #FCF4B0
}
.card4{
background-color: #FFB1B0
}
.card5{
background-color: #8AC9FF
}
.classname {
background-color:#44c767;
text-indent:0;
display:inline-block;
color:#ffffff;
font-size:15px;
font-style:normal;
height:50px;
line-height:50px;
width:140px;
text-decoration:none;
text-align:center;
}.classname:hover {
background-color:#5cbf2a;
}.classname:active {
position:relative;
top:1px;
}
* {
box-sizing: border-box;
}
/* Create two equal columns that floats next to each other */
.column {
float: left;
width: 50%;
padding: 10px;
height: 300px; /* Should be removed. Only for demonstration */
}
/* Clear floats after the columns */
.row:after {
content: "";
display: table;
clear: both;
}
<div class="wrapper">
<div class="card1">
<div class="column">
<h2><span>Project #1</span>Title of the Project</h2>
<p>Lorem ipsum dolor sit, amet consectetur adipisicing elit. Harum, perspiciatis blanditiis accusamus commodi consectetur id tempora rem iure eligendi quos eos et autem ratione exercitationem earum laborum ad a sequi!</p>
Know More
</div>
<div class="column">
<img src="http://cdn.pixabay.com/photo/2015/03/26/09/47/sky-690293_960_720.jpg" alt="Girl in a jacket" width="250" height="300">
</div>
</div>
<div class="card2">
<h2><span>Project #2</span>Title of the Project</h2>
<p>Lorem ipsum dolor sit, amet consectetur adipisicing elit. Harum, perspiciatis blanditiis accusamus commodi consectetur id tempora rem iure eligendi quos eos et autem ratione exercitationem earum laborum ad a sequi!</p>
</div>
<div class="card3">
<h2><span>Project #3</span>Title of the Project</h2>
<p>Lorem ipsum dolor sit, amet consectetur adipisicing elit. Harum, perspiciatis blanditiis accusamus commodi consectetur id tempora rem iure eligendi quos eos et autem ratione exercitationem earum laborum ad a sequi!</p>
</div>
<div class="card4">
<h2><span>Project #4</span>Title of the Project</h2>
<p>Lorem ipsum dolor sit, amet consectetur adipisicing elit. Harum, perspiciatis blanditiis accusamus commodi consectetur id tempora rem iure eligendi quos eos et autem ratione exercitationem earum laborum ad a sequi!</p>
</div>
<div class="card5">
<h2><span>Project #5</span>Title of the Project</h2>
<p>Lorem ipsum dolor sit, amet consectetur adipisicing elit. Harum, perspiciatis blanditiis accusamus commodi consectetur id tempora rem iure eligendi quos eos et autem ratione exercitationem earum laborum ad a sequi!</p>
</div>
</div>
Please check the Snipped just added code to divide div in 2 columns
Maybe utilize flex and some align-items to attain the centering effect.
.image-box-wrap
{ background-color: Black;
padding: 20px;
}
.image-box
{ background-color: White;
display: flex;
justify-content: space-between;
}
.image-box > *
{ display: flex;
flex-direction: column;
justify-content: center;
}
.image-box .text
{ flex: 1 1 0%;
box-sizing: border-box;
padding: 1em;
align-items: flex-start;
}
.image-box .text a
{ background-color: Orange;
padding: 10px;
color: White;
text-decoration: none;
}
.image-box .image
{ background-color: Teal;
width: 40%;
height: 240px;
}
.image-box .image img
{ display: block;
width: 100%;
}
<div class="image-box-wrap">
<div class="image-box">
<div class="text">
<h2>Card One</h2>
<p>Text goes here... (if you have a bunch of text, you'll attain the sticky positioning where the image follows along with the text that you had in your example as the page scrolls down)</p>
Button
</div>
<div class="image">
IMG tag goes here
</div>
</div>
</div>
I'm just a beginner and I've got a problem with an easy task. I need to make a side menu that is half-hidden behind the screen. Something like that Example of hover menu. I want it to appear from the right when I hover it. Using my code below, a horizontal scroll appears. I can't give overflow:hidden to body because I need to scroll the page later. Give me some hints, please
Don't pay attention to styles, I need this task just for practice :)
<div class="wrapper">
<div class="main-content">
<h1> Lorem ipsum dolor sit amet consectetur adipisicing elit. Rem, aliquam!</h1>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Porro assumenda sint totam fugiat earum fugit? Obcaecati
blanditiis nobis voluptatum enim labore nihil amet inventore ad? Est perspiciatis nam amet dicta laudantium
vel dolor rerum minima quas non excepturi, repellat sequi!</p>
</div>
</div>
<div class="hover-menu">
About Us
Contacts
Location
Price
Cooperation
</div>
body{
background: url('/images/broken-lights.jpg') no-repeat 0 0/cover;
text-align: center;
width: 100%;
position: relative;
}
.wrapper{
padding-top: 100px;
width: 1200px;
min-height: 400px;
margin: 0 auto;
background: linear-gradient(black 0px, rgba(0,0,0, 0) 90%);
border-radius: 40px;
box-shadow: 0 0 10px;
}
.hover-menu{
position: absolute;
display: inline-block;
top: 50%;
transform: translate(0,-50%);
right: -40px;
}
.hover-menu a{
display: block;
background: turquoise;
padding: 10px 20px;
margin-bottom: 10px;
border-radius: 40px;
}
You will need the side menu just when you are wishing to click. So using overflow:hidden; will help. You can keep vertical scroll while eliminating horizontal-scroll. Here's how I would do -
body{
background: url('/images/broken-lights.jpg') no-repeat 0 0/cover;
text-align: center;
width: 100%;
position: relative;
overflow-X: hidden;
}
.wrapper{
padding-top: 100px;
width: 1200px;
min-height: 400px;
margin: 0 auto;
background: linear-gradient(black 0px, rgba(0,0,0, 0) 90%);
border-radius: 40px;
box-shadow: 0 0 10px;
overflow-X:hidden;
}
.hover-menu{
position: absolute;
display: block;
top: 25%;
right: -40px;
}
.hover-menu a{
display: block;
background: turquoise;
padding: 10px 20px;
margin-bottom: 10px;
border-radius: 40px;
}
.hover-menu:hover{
transform:translateX(-40px);
transition-duration:1s;
}
.hover-menu a:hover{
transform:translateX(-40px);
transition-duration:1s;
}
.hover-menu a{
transition-duration:0.5s;
}
.hover-menu{
transition-duration:0.5s;
}
<div class="wrapper">
<div class="main-content">
<h1> Lorem ipsum dolor sit amet consectetur adipisicing elit. Rem, aliquam!</h1>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Porro assumenda sint totam fugiat earum fugit? Obcaecati
blanditiis nobis voluptatum enim labore nihil amet inventore ad? Est perspiciatis nam amet dicta laudantium
vel dolor rerum minima quas non excepturi, repellat sequi!</p>
</div>
</div>
<div class="hover-menu">
About Us
Contacts
Location
Price
Cooperation
</div>
There's no scrollbar appearing. You probably would only need to scroll vertically. So you can just use overflow-X:hidden;. You code lacks responsiveness with screen-size, but with the above code , you can just hover on the menu to make it appear and you code would work fine for desktop screens.
I have made few changes to make the side-menu look appropriately located and the animations/transitions look smooth.
Hope this helps !
Website: http://www.asia-hr.com > Home > Team > click on any faces
On my team section, when you click on a face, the bio is popping up. However, I am facing two problems:
1) It's going down very far on click, I would like to be more centered on the picture and bio.
2) I would like to have a slower transition
Do you have any ideas of what can be the issue and how can I fix it?
CSS:
.team-section{
overflow:hidden;
text-align:center;
background: #34495e;
padding: 60px;
}
.team-section h2{
color: white;
}
.ps{
margin-bottom: 40px;
}
.team-section .ps .p{
width: 250px;
height: 250px;
overflow:hidden;
border-radius: 50%;
margin: 0 30px;
display:inline-block;
-webkit-border-radius: 50%;
-webkit-transform: translateZ(0);
-webkit-mask-image: -webkit-radial-gradient(circle, white, black);
}
.team-section .ps .p img{
height: 100%;
min-width: 100%;
left: 50%;
position: relative;
transform: translateX(-50%);
filter:grayscale(100%);
transition: 0.5s all;
}
.team-section .ps .p img:hover{
filter: none;
}
.team-section .section{
width:600px;
margin:auto;
font-size: 20px;
color:white;
text-align: justify;
height: 0;
overflow: hidden;
}
.team-section .section:target{
height: auto;
}
.team-section .name{
display:block;
font-size: 22px;
text-align: center;
}
.stop-scrolling {
height: 100%;
overflow: hidden;
}
HTML
<div class="team-section">
<h2>Our Team</h2>
<span class="border border-1"></span>
<div class="ps">
<div class="p">
<img src="./images/home/h1.jpg">
</div>
<div class="p">
<img src="./images/home/h2.jpg">
</div>
<div class="p">
<img src="./images/home/h3.jpg">
</div>
</div>
<div class="section" id="p1">
<span class="name">Sophia Letana</span>
<span class="border border-1"></span>
<p>Lorem ipsum dolor sit, amet consectetur adipisicing elit. Placeat tenetur assumenda omnis, rem, quas quae odit, voluptatem dolorum quod corrupti sint doloribus aspernatur? Quasi, dolore?</p>
</div>
<div class="section" id="p2">
<span class="name">Francois Le Chene</span>
<span class="border border-1"></span>
<p>gh ghgh ghg sit, amet consectetur ghgh elit. Placeat tenetur assumenda omnis, rem, quas quae odit, voluptatem dolorum quod corrupti sint doloribus aspernatur? Quasi, dolore?</p>
</div>
<div class="section" id="p3">
<span class="name">Steve Mansoa</span>
<span class="border border-1"></span>
<p>Lghgh ipsum gh sit, amet consectetur adipisicing elit. Placeat tenetur assumenda omnis, rem, quas quae odit, voluptatem dolorum quod corrupti sint doloribus aspernatur? Quasi, dolore?</p>
</div>
</div>
what I am trying to accomplish is to make a frosty glass effect for a header. The header has a white background with black text and is fixed. The idea is that the content that is behind this header (when scrolling down) is shown with the frosty glass effect.
I succeeded partly by changing the opacity of my header to 0.9, but I can't get the blur effect (via filter) to work. Anybody an idea what I have to change? Here is my code:
html,
body {
position: relative;
width: 100%;
height: 100%;
overflow: auto;
overflow-x: hidden;
color: black;
}
* {
margin: 0;
padding: 0;
}
body {
box-sizing: border-box;
font-family: "Roboto", sans-serif;
font-size: 16px;
}
main {
width: 100%;
background: lightblue;
section {
padding: 80px;
}
h1 {
margin-bottom: 20px;
}
p {
margin-bottom: 20px;
}
}
.outer-header {
// background-repeat: no-repeat;
// background-attachment: fixed;
// background-size: cover;
// background-position: top;
// background-image: url(https://4bp.blogspot.com/-1f1sdfix3dy/Uh92eZAQ90I/AAAAAAAAHM4/5oiB4zC_tQ4/s1600/Photo-Background-White4.jpg);
background: white;
height: 80px;
position: sticky;
top: 0px;
left: 0px;
opacity: 0.9;
overflow: hidden;
z-index:4;
&::after {
z-index: -1;
content: "";
background: inherit;
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
box-shadow: inset 0 0 200px rgba(255, 255, 255, 0.05);
filter: blur(10px);
// filter: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg'><filter id='svgMask'><feGaussianBlur stdDeviation='10' /></filter></svg>#svgMask");
}
}
header {
display: flex;
align-items: center;
justify-content: space-between;
height: 100%;
}
img {
height: 50px;
cursor: pointer;
object-fit: cover;
}
h1 {
position: relative;
}
.logo-text {
font-size: 33px;
position: absolute;
left: 50px;
top: 6px;
}
nav,
ul {
display: flex;
grid-column-gap: 20px;
justify-items: end;
align-items: center;
}
<div class="outer-header">
<header>
<h1>
<img src="https://source.unsplash.com/random/287x287" />
<span class="logo-text">Company</span>
</h1>
<nav>
<li>Link 1</li>
<li>Link 2</li>
<li>Link 3</li>
</nav>
</header>
</div>
<main>
<section>
<h1>Heading</h1>
<p>
Lorem ipsum dolor sit, amet consectetur adipisicing elit. Hic est autem vel
nam laborum ad at! Labore iusto quae porro nostrum dicta esse consequatur
sit. Repellat quia deleniti enim in.
</p>
</section>
<section>
<h1>Heading</h1>
<p>
Lorem ipsum dolor sit, amet consectetur adipisicing elit. Hic est autem vel
nam laborum ad at! Labore iusto quae porro nostrum dicta esse consequatur
sit. Repellat quia deleniti enim in.
</p>
</section>
<section>
<h1>Heading</h1>
<p>
Lorem ipsum dolor sit, amet consectetur adipisicing elit. Hic est autem vel
nam laborum ad at! Labore iusto quae porro nostrum dicta esse consequatur
sit. Repellat quia deleniti enim in.
</p>
</section> <section>
<h1>Heading</h1>
<p>
Lorem ipsum dolor sit, amet consectetur adipisicing elit. Hic est autem vel
nam laborum ad at! Labore iusto quae porro nostrum dicta esse consequatur
sit. Repellat quia deleniti enim in.
</p>
</section> <section>
<h1>Heading</h1>
<p>
Lorem ipsum dolor sit, amet consectetur adipisicing elit. Hic est autem vel
nam laborum ad at! Labore iusto quae porro nostrum dicta esse consequatur
sit. Repellat quia deleniti enim in.
</p>
</section>
</main>
You are looking for the (still experimental) backdrop-filter property. However, browser support is still a bit scarce. For Firefox, it will land in the upcoming version 70 behind a developer flag. Safari still requires the -webkit- vendor prefix. But you can test this working example in a current version (76+) of Chrome.
body {
background: url(http://placekitten.com/800/600) no-repeat;
}
#overlay {
width: 50vw;
height: 50vh;
background: rgba(255,255,255,0.4);
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
backdrop-filter: blur(10px);
-webkit-backdrop-filter: blur(10px);
}
<div id="overlay"></div>
I'm trying to make a fixed navbar at the top of my webpage, it's all pure HTML and CSS for now. The problem comes as a result of the fact that I want a button on the left side to open up a sidebar for navigation on mobile. I want to position the three navbar items in the center of the navbar, evenly spaced from eachother. As previously stated, I also want the navbar to be fixed so that it is visible no matter where the user scrolls on the page.
Here's the HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Cyberpunk Bar</title>
<link href="https://stackpath.bootstrapcdn.com/bootswatch/4.1.1/lux/bootstrap.min.css" rel="stylesheet" integrity="sha384-4KIc2mnKfAA7VjirNLk2Sqp7jxFNq1q8+FhYGxhW2l52lt4HJsfksL+hjswHfbl/" crossorigin="anonymous">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.0.13/css/all.css" integrity="sha384-DNOHZ68U8hZfKXOrtjWvjxusGo9WQnrNx2sqG0tfsghAvtVlRW3tvkXWZh58N9jp" crossorigin="anonymous">
<link rel="stylesheet" href="style.css">
</head>
<div id="navbar">
<ul id="navbar-menu">
<li>
<span class="open-slide">
<a href="#" onclick="">
<div><i id="open-button" class="fab fa-bitcoin"></i></div>
</a>
</span>
</li>
<li>Theme</li>
<li>Beer</li>
<li>Menu<li>
</ul>
</div>
<body>
<div class="pimg1">
<div class="ptext">
<span class="border">Cyberpunk Bar and Grill</span>
</div>
</div>
<section class="section section-light">
<h2>Section 1</h2>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Dolor enim quis explicabo perspiciatis nemo nesciunt ducimus, aut eos iste modi amet, illo est eveniet at porro debitis excepturi neque nisi! <br>
<p>Lorem ipsum dolor, sit amet consectetur adipisicing elit. Eaque neque expedita at fugit voluptates veritatis temporibus ab dignissimos et nihil? Repellendus debitis possimus consectetur facilis nostrum natus fugit voluptatibus modi?</p>
</section>
<div class="pimg2">
<div class="ptext">
<span class="border">Brilliant Beer Selection</span>
</div>
</div>
<section class="section section-light">
<h2>Section 2</h2>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Dolor enim quis explicabo perspiciatis nemo nesciunt ducimus, aut eos iste modi amet, illo est eveniet at porro debitis excepturi neque nisi! <br>
<p>Lorem ipsum dolor, sit amet consectetur adipisicing elit. Eaque neque expedita at fugit voluptates veritatis temporibus ab dignissimos et nihil? Repellendus debitis possimus consectetur facilis nostrum natus fugit voluptatibus modi?</p>
</p>
</section>
<div class="pimg3">
<div class="ptext">
<span class="border">Burgers and Steak</span>
</div>
</div>
<section id="section3" class="section section-dark">
<h2>Section 3</h2>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Dolor enim quis explicabo perspiciatis nemo nesciunt ducimus, aut eos iste modi amet, illo est eveniet at porro debitis excepturi neque nisi! <br>
<p>Lorem ipsum dolor, sit amet consectetur adipisicing elit. Eaque neque expedita at fugit voluptates veritatis temporibus ab dignissimos et nihil? Repellendus debitis possimus consectetur facilis nostrum natus fugit voluptatibus modi?</p>
</section>
<div class="pimg4">
<div class="ptext">
<span class="border">What are you waiting for?</span>
</div>
</div>
</body>
</html>
Here's the CSS
body, html
{
height: 100%;
margin: 0;
padding: 0;
font-size: 18px;
font-family: "Lato", sans-serif;
font-weight: 400;
line-height: 1.8em;
color: #666;
}
#navbar
{
height: 100px;
background-color: black;
z-index: 1;
overflow: hidden;
margin: 0;
padding: 10;
filter:drop-shadow(0 5px 15px black);
}
#navbar-menu
{
display: inline-block;
text-align: center;
text-decoration: none;
list-style: none;
font-size: 25px;
margin: 0;
padding: 0;
color: white;
}
#open-button
{
color: white;
font-size: 50px;
padding-bottom: 25px;
padding-top: 25px;
}
#open-button:hover
{
color: #666;
}
.pimg1, .pimg2, .pimg3, .pimg4
{
position: relative;
opacity: 0.70;
background-position: center;
background-size: cover;
background-repeat: no-repeat;
/* fixed = parallax, scroll = normal */
background-attachment: fixed;
}
.pimg1
{
background-image:url('https://i.imgur.com/bHJ4vHL.jpg?1');
min-height: 100%;
}
.pimg2
{
background-image:url('https://images.pexels.com/photos/338711/pexels-photo-338711.jpeg?cs=srgb&dl=alcohol-alcoholic-alcoholic-beverage-338711.jpg&fm=jpg');
min-height: 400px;
}
.pimg3
{
background-image:url('https://images.pexels.com/photos/156114/pexels-photo-156114.jpeg?cs=srgb&dl=beef-bread-burger-156114.jpg&fm=jpg');
min-height: 400px;
}
.pimg4
{
background-image:url('https://images.pexels.com/photos/696218/pexels-photo-696218.jpeg?cs=srgb&dl=adult-bar-blur-696218.jpg&fm=jpg');
min-height: 400px;
}
.section
{
text-align: center;
padding: 50px 80px;
}
.section-light
{
background-color: #f4f4f4;
color: #666;
}
.section-dark
{
background-color: #282E34;
color: #DDD;
}
.ptext
{
position: absolute;
top: 50%;
width: 100%;
text-align: center;
color: #000;
font-size: 32px;
letter-spacing: 8px;
text-transform: uppercase;
}
.ptext .border
{
background-color: #111;
color: white;
padding: 20px;
}
Is using a the best practice for this? Please help!
$(".open-slide").click(function() {
$(this).toggleClass("opend");
});
body,
html {
height: 100%;
margin: 0;
padding: 0;
font-size: 18px;
font-family: "Lato", sans-serif;
font-weight: 400;
line-height: 1.8em;
color: #666;
}
#navbar {
height: 100px;
background-color: black;
z-index: 1;
overflow: hidden;
margin: 0;
padding: 10;
filter: drop-shadow(0 5px 15px black);
}
#navbar-menu {
display: inline-block;
text-align: center;
text-decoration: none;
list-style: none;
font-size: 25px;
margin: 0;
padding: 0;
color: white;
}
#open-button {
color: white;
font-size: 50px;
padding-bottom: 25px;
padding-top: 25px;
display:none;
}
#open-button:hover {
color: #666;
}
.pimg1 {
/*margin-top:100px;*/
}
.pimg1,
.pimg2,
.pimg3,
.pimg4 {
position: relative;
opacity: 0.70;
background-position: center;
background-size: cover;
background-repeat: no-repeat;
/* fixed = parallax, scroll = normal */
background-attachment: fixed;
}
.pimg1 {
background-image: url('https://i.imgur.com/bHJ4vHL.jpg?1');
min-height: 100%;
}
.pimg2 {
background-image: url('https://images.pexels.com/photos/338711/pexels-photo-338711.jpeg?cs=srgb&dl=alcohol-alcoholic-alcoholic-beverage-338711.jpg&fm=jpg');
min-height: 400px;
}
.pimg3 {
background-image: url('https://images.pexels.com/photos/156114/pexels-photo-156114.jpeg?cs=srgb&dl=beef-bread-burger-156114.jpg&fm=jpg');
min-height: 400px;
}
.pimg4 {
background-image: url('https://images.pexels.com/photos/696218/pexels-photo-696218.jpeg?cs=srgb&dl=adult-bar-blur-696218.jpg&fm=jpg');
min-height: 400px;
}
.section {
text-align: center;
padding: 50px 80px;
}
.section-light {
background-color: #f4f4f4;
color: #666;
}
.section-dark {
background-color: #282E34;
color: #DDD;
}
.ptext {
position: absolute;
top: 50%;
width: 100%;
text-align: center;
color: #000;
font-size: 32px;
letter-spacing: 8px;
text-transform: uppercase;
}
.ptext .border {
background-color: #111;
color: white;
padding: 20px;
}
/* new css */
.open-slide {
display: none;
}
#navbar-menu {
display: -webkit-box;
display: -moz-box;
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
-webkit-flex-flow: row wrap;
justify-content: space-around;
}
#navbar-menu>li {
height: 100px;
line-height: 100px;
}
.menus-nav.fixed-header {
position: fixed;
right: 0;
left: 0;
z-index: 1030;
}
#media(max-width:767px) {
.open-slide {
display: block;
}
.open-slide+#navbar-menu {
max-height: 0;
position: relative;
-webkit-transition: max-height 1000ms ease;
transition: max-height 1000ms ease;
overflow: hidden;
}
.open-slide.opend+#navbar-menu {
max-height: 300px;
}
#navbar {
height: auto;
}
#navbar-menu {
display: block !important;
display: block !important;
display: block !important;
display: block !important;
display: block !important;
-webkit-flex-flow: inherit !important;
justify-content: inherit !important;
}
#navbar-menu>li {
height: auto;
}
#navbar-menu>li {
height: auto;
line-height: 1em;
padding: 10px 15px;
text-align: left;
border-bottom: 1px solid #222222;
}
#open-button {
display:block;
}
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/todc-bootstrap/3.3.7-3.3.13/css/bootstrap.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/todc-bootstrap/3.3.7-3.3.13/js/bootstrap.min.js" type="text/javascript"></script>
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.0.13/css/all.css" integrity="sha384-DNOHZ68U8hZfKXOrtjWvjxusGo9WQnrNx2sqG0tfsghAvtVlRW3tvkXWZh58N9jp" crossorigin="anonymous">
<body>
<!-- menu -->
<div id="navbar" class="menus-nav fixed-header">
<i id="open-button" class="fab fa-bitcoin open-slide" onclick=""></i>
<ul id="navbar-menu">
<li>Theme</li>
<li>Beer</li>
<li>Menu</li>
</ul>
</div>
<!-- menu -->
<div class="pimg1">
<div class="ptext">
<span class="border">Cyberpunk Bar and Grill</span>
</div>
</div>
<section class="section section-light">
<h2>Section 1</h2>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Dolor enim quis explicabo perspiciatis nemo nesciunt ducimus, aut eos iste modi amet, illo est eveniet at porro debitis excepturi neque nisi! <br>
<p>Lorem ipsum dolor, sit amet consectetur adipisicing elit. Eaque neque expedita at fugit voluptates veritatis temporibus ab dignissimos et nihil? Repellendus debitis possimus consectetur facilis nostrum natus fugit voluptatibus modi?</p>
</section>
<div class="pimg2">
<div class="ptext">
<span class="border">Brilliant Beer Selection</span>
</div>
</div>
<section class="section section-light">
<h2>Section 2</h2>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Dolor enim quis explicabo perspiciatis nemo nesciunt ducimus, aut eos iste modi amet, illo est eveniet at porro debitis excepturi neque nisi! <br>
<p>Lorem ipsum dolor, sit amet consectetur adipisicing elit. Eaque neque expedita at fugit voluptates veritatis temporibus ab dignissimos et nihil? Repellendus debitis possimus consectetur facilis nostrum natus fugit voluptatibus modi?
</p>
</section>
<div class="pimg3">
<div class="ptext">
<span class="border">Burgers and Steak</span>
</div>
</div>
<section id="section3" class="section section-dark">
<h2>Section 3</h2>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Dolor enim quis explicabo perspiciatis nemo nesciunt ducimus, aut eos iste modi amet, illo est eveniet at porro debitis excepturi neque nisi! <br>
<p>Lorem ipsum dolor, sit amet consectetur adipisicing elit. Eaque neque expedita at fugit voluptates veritatis temporibus ab dignissimos et nihil? Repellendus debitis possimus consectetur facilis nostrum natus fugit voluptatibus modi?</p>
</section>
<div class="pimg4">
<div class="ptext">
<span class="border">What are you waiting for?</span>
</div>
</div>
</body>
First of all our <div id="navbar"> have to be inside <body> tag.
Check here for edited parts of code:
HTML:
<body>
<div id="navbar">
<ul id="navbar-menu">
<li>
<span class="open-slide">
<a href="#" onclick="">
<div><i id="open-button" class="fab fa-bitcoin"></i></div>
</a>
</span>
</li>
<li>Theme</li>
<li>Beer</li>
<li>Menu<li>
</ul>
</div>
.....
</body>
</html>
CSS:
#navbar {
position: fixed;
top: 0;
width: 100%;
height: 100px;
background-color: black;
z-index: 1;
overflow: hidden;
margin: 0;
padding: 10;
filter:drop-shadow(0 5px 15px black);
}
#navbar-menu {
width: max-content;
margin: 0 auto;
}
#navbar-menu li {
display: inline-block;
text-align: center;
text-decoration: none;
list-style: none;
font-size: 25px;
margin: 0;
padding: 0 40px;
color: white;
}
https://codepen.io/Yulia_pi/pen/yjRQgy