Create a centered GDPR banner - html

I am new with HTML and CSS and I am trying to create a simple banner that contain a text and two buttons. The banner should looks to something like this enter image description here
This is my code:
.banner{
position: absolute;
width:90%;
display:inline-block;
bottom:50px;
height: 150px;
background: rgba(215, 40, 40, 0.9);
left:0px;
right: 0px;
margin: 0 auto;
z-index: 100;
display:inline-block;
}
.banner more_info_btn {
float:right;
}
.banner ok_btn {
float:right;
}
<div class="banner">
<p> some text</p>
<div class="more_info_btn">more info</li>
<div class="ok_btn">ok</li>
</div>
I am not sure how to align the text and the buttons horizontally and vertically. Do you have an idea about the problem?

If you want use position absolute parent has to be in container with position relative
.banner{
width:90%;
align-items: center;
text-align:center;
height: 150px;
background: rgba(215, 40, 40, 0.9);
margin: 0 auto;
display:flex;
justify-content: center;
}
.wrap-text{width:100%;}
.more_info_btn {
display:inline;
margin:5px;
}
.ok_btn {
padding:5px;
display:inline
}
<div class="banner">
<div class="wrap-text">
<p> textsome textsometext</p>
<div class="more_info_btn">more info</div>
<div class="ok_btn">ok</div>
</div>
</div>

Related

How to make popup position relative to overall page instead of button that triggered it

I am trying to code a pop-up that triggers when an image is clicked, and it is essentially working but the popup is aligning itself to the image that triggered it. I need to align it to the center of the overall page, I have tried messing with the margins and setting all the div class to align="center" but none of that has helped. This is inside an Elementor widget, which I believe is basically just a CSS flexbox.
<div class="popup">
<img src="image1.png">
</div>
<div class="showcompliant">
<div class="overlay"></div>
<div class="img-showcompliant" align="center">
<div align="right"><span>X</span></div>
<div class="icon">
</div>
<div class="description">
Lorem ipsum dolor amet sit.
</div>
<div class="illustrationcomplaints"></div>
<style>
.illustrationcomplaints {
background-image: url("image2.png");
background-repeat: no-repeat;
width:600px;
height: 100px;
}
</style>
<div align="center">
<div class="dismiss-btn">
</div>
</div>
</div>
</div>
<style>
.popup{
margin: auto;
text-align: center
}
.popup:hover {
position: relative;
top: -5px;
}
.popup img{
width: 390px;
height: 140px;
cursor: pointer
z-index: 75;
}
.showcompliant{
display: none;
z-index: 101;
align-self: center;
margin-left: 50%;
margin-right: 50%;
}
.showcompliant .img-showcompliant{
width:650px;
height:350px;
align-content: center;
background: #F2F2F2;
padding: 20px;
position: relative;
z-index: 100;
}
.img-showcompliant span{
position: absolute;
cursor: pointer;
}
.img-showcompliant img{
top: 0;
left: 0;
}
.description {
padding:25px;
color: #1a1a1a;
}
.overlay {
align-content: center;
}
</style>
<script>
$(function () {
"use strict";
$(".popup img").click(function () {
var $src = $(this).attr("src");
$(".showcompliant").fadeIn();
$(".img-showcompliant img").attr("src", $src);
});
$("span, .overlay").click(function () {
$(".showcompliant").fadeOut();
});
});
</script>
Good day. Try to help you...
As I understand you need to use flexbox and use "flex-direction: column;"
Please see this pretty simple html + css how to use it.
Let me know if it helps you?
html,body{
height:100%;
padding:0;
margin:0;
}
*{
box-sizing:border-box;
}
.box{
width:100px;
height:100px;
background-color:blue;
}
.container{
width:100%;
height:100%;
background-color:#ccc;
flex-direction:column;
display:flex;
justify-content:center;
align-items:center;
}
<div class="container">
<div class="box"></div>
<img src="https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_92x30dp.png">
</div>

CSS - prevent border from moving on scroll

When the browser window is resized, the borders are shifting away from the content?
How can I achieve a design where the border remains in one place, no matter the height of the window?
.story_header {
position: relative;
display: flex;
justify-content: center;
}
.story_header:before,
.story_header:after {
content: '';
width: 100px;
position: absolute;
border: 2px solid black;
margin-top: 20px;
left: 35%;
}
.story_header:after {
right: 35%;
left: auto;
}
<div class='section_1'>
<div class="grid-x">
<div class='large-12 cell'>
<h2 class='story_header'>Our Story</h2>
</div>
</div>
You need to wrap the 'Our Story' to an element let's say span then add the pseudo elements on that span. Try this:
CSS:
.story_header{
position:relative;
display:flex;
justify-content: center;
}
.story_title{
position:relative;
}
.story_title:before, .story_title:after{
content:'';
width:100px;
position:absolute;
border:2px solid black;
margin-top:20px;
}
.story_title:before{
right:100%;
}
.story_title:after{
left:100%;
}
HTML:
<div class="grid-x">
<div class='large-12 cell'>
<h2 class='story_header'> <span class="story_title">Our Story</span></h2>
</div>
</div>

CSS forced top z-index with parent overflow:hidden

I can't sort out how to move the element, which is placed under .content-wrapper{ overflow:hidden; .content{position:absolute;} }, to the very top.
Consider a screenshot below:
An image element with man photo is placed under the .content element. But the part of his head on photo, which is highlighted with yellow (pointed with red arrow) is hidden due to the parent .content-wrapper has an overflow:hidden property. The main problem is that I can't change the hidden overflow to whatever else.
Is that actually real to solve such a problem without using a JavaScript?
==== Supplement 1 ====
To clarify the problem, I've made up a code snippet below:
.wrapper{
width:100%;
overflow:hidden;
position:initial;
padding:0 10px;
background-color:#EEEEEE;
box-sizing:border-box;
}
.content-wrapper{
position:relative;
overflow:hidden;
background-color:#DDDDDD;
margin:10px 0;
min-height:350px;
}
.content{
background-color:white;
position:absolute;
top:30px;
left:10px;
right:10px;
bottom:10px;
}
.content.grayed{
background-color:#CCCCCC;
}
.content.positioned{
top:50px;
left:180px;
bottom:-50px; //negative positioned parts supposed to be hidden
right:-50px; //as .content-wrapper has overflow:hidden;
}
.content.positioned img{
width:40%;
height:auto;
margin-top:-40vh; //but that is not supposed to be hidden out of .content-wrapper
margin-left:10vw;
min-width:250px;
}
<div class="wrapper">
.wrapper
<div class="content-wrapper">
.content-wrapper
<div class="content grayed" style="transform: rotate(-35deg); padding:20px;">
<strong>.content</strong> with cut off edges - that is supposed behaviour
</div>
</div>
<div class="content-wrapper">
.content-wrapper
<div class="content positioned">
<strong>.content</strong>
<img src="//i.imgur.com/DsOdy1V.png">
<br>
...and a man above is with sliced head - that is UNsupposed behaviour
</div>
</div>
</div>
Is there really no any solution?
I would consider adding the image outside and adjust the position to obtain this. Change the translation to adjust the position:
.wrapper {
width: 100%;
overflow: hidden;
position: relative; /*change this*/
padding: 0 10px;
background-color: #EEEEEE;
box-sizing: border-box;
}
.content-wrapper {
position: relative;
overflow: hidden;
background-color: #DDDDDD;
margin: 10px 0;
min-height: 350px;
}
.content {
background-color: white;
position: absolute;
top: 30px;
left: 10px;
right: 10px;
bottom: 10px;
}
.content.grayed {
background-color: #CCCCCC;
}
.content.positioned {
top: 50px;
left: 180px;
bottom: 0;
right: 0;
padding: 20px calc(40% - 0.4*148px) 0 20px; /* the space of the image*/
}
.content.positioned img {
position: absolute;
opacity: 0; /*Hide this one*/
}
.hack {
/*Don't use any top/bottom here !!*/
left: 190px;
right: 10px;
position: absolute;
z-index: 1;
}
.hack img {
width: 40%;
position: absolute;
right: 0;
bottom: 0;
transform: translateY(70%);
max-width:300px;
}
<div class="wrapper">
.wrapper
<div class="content-wrapper">
.content-wrapper
<div class="content grayed" style="transform: rotate(-35deg); padding:20px;">
<strong>.content</strong> with cut off edges - that is supposed behaviour
</div>
</div>
<div class="hack">
<img src="//i.imgur.com/DsOdy1V.png">
</div>
<div class="content-wrapper">
.content-wrapper
<div class="content positioned">
<strong>.content</strong>
<img src="//i.imgur.com/DsOdy1V.png">
<br> ...and a man above is with sliced head - that is UNsupposed behaviour
</div>
</div>
</div>
Add a <div> like content-wrapper-inner and move the height, position from content-wrapper into it.
.wrapper{
width:100%;
overflow:hidden;
position:initial;
padding:0 10px;
background-color:#EEEEEE;
box-sizing:border-box;
}
.content-wrapper{
overflow:hidden;
background-color:#DDDDDD;
margin:10px 0;
}
.content{
background-color:white;
position:absolute;
top:30px;
left:10px;
right:10px;
bottom:10px;
}
.content-wrapper-inner {
min-height:350px;
position:relative;
background-color: red;
}
.content.grayed{
background-color:#CCCCCC;
}
.content.positioned{
top:50px;
left:180px;
bottom:-50px; //negative positioned parts supposed to be hidden
right:-50px; //as .content-wrapper has overflow:hidden;
}
.content.positioned img{
width:40%;
height:auto;
margin-top:-40vh; //but that is not supposed to be hidden out of .content-wrapper
margin-left:10vw;
min-width:250px;
}
<div class="wrapper">
.wrapper
<div class="content-wrapper">
.content-wrapper
<div class="content grayed" style="transform: rotate(-35deg); padding:20px;">
<strong>.content</strong> with cut off edges - that is supposed behaviour
</div>
</div>
<div class="content-wrapper">
.content-wrapper
<div class="content-wrapper-inner">
<div class="content positioned">
<strong>.content</strong>
<img src="//i.imgur.com/DsOdy1V.png">
<br>
...and a man above is with sliced head - that is UNsupposed behaviour
</div>
</div>
<div class="content positioned">
<strong>.content</strong>
<img src="//i.imgur.com/DsOdy1V.png">
<br>
...and a man above is with sliced head - that is UNsupposed behaviour
</div>
</div>
</div>
Try to make overflow:visibleof the outer div of the content.
You can't have content reach out of a parent with overflow: hidden and still find a way to show the head. The question is why you need overflow hidden on the parent.
Perhaps you could use a sibling element for the image container and limit overflow on the content container.
Something like:
HTML
<div class="parent">
<div class="child-content-wrapper">
Content goes here
</div>
<div class="child-image">
Image goes here
</div>
</div>
CSS:
.parent {
position: relative;
}
.child-content-wrapper {
overflow: hidden;
}
.child-image {
position: absolute;
right: 0;
bottom: 0;
z-index: 1;
}
That should work and you'll be able to get the cut off effect on the rotated content box and the whole head.

Aligning multiple Divisions within a Division

I need to align multiple DIVs horizontally and vertically inside my main DIV divBig. Each DIV should overlap one over the other but should be in the centre of the main DIV divBig.
This is my DIV structure:
<div id="divBig">
<div class="divBigInner">
<img class="innerSub1" src="image.png" />
<div class="innerSub2"></div>
<div class="innerSub3"></div>
</div>
</div>
This is what I tried so far. But Does not align correctly.
#divBig {
background-color: #ff6600;
text-align: center;
}
.divBigInner{
position:relative;
height: 100%;
}
.innerSub1{
position:absolute;
max-width:550px;
width:100%;
z-index: 1;
margin: auto;
pointer-events: none;
}
.innerSub2{
position:absolute;
z-index: 2;
top:10px;
display:inline;
}
.innerSub3{
position:relative;
max-width:550px;
width:100%;
z-index:0;
margin: auto;
pointer-events: none;
}
Thank you.
like this you are asking?
<div id="divBig">
<div class="divBigInner" align="center">
<div class="innerSub1"></div>
<div class="innerSub2"></div>
<div class="innerSub3"></div>
</div>
</div>
Css
<style>
#divBig {
background-color: #fff;
text-align: center;
}
.divBigInner{
height: 100%;
}
.innerSub1,.innerSub2,.innerSub3{
border:1px solid #f00;
padding:10px;
margin:10px;
width:100px;
}
</style>
Can you try this:
<div id="divBig">
<div class="divBigInner" align="center">
<div class="innerSub1"></div>
<div class="innerSub2"></div>
<div class="innerSub3"></div>
</div>
</div>
Css
<style>
#divBig {
background-color: #fff;
text-align: center;
}
.divBigInner{
height: 100%;
position:relative;
}
.innerSub1,.innerSub2,.innerSub3{
border:1px solid #f00;
padding:10px;
margin:10px;
width:100px;
height:100px;
position:absolute;
margin-left:-50px; /*formula to make div center horizontal (left 50% - width/2)*/
margin-top:-50px; /*formula to make div center vertical (top 50% - height/2)*/
}
</style>

How can I vertically center text over a responsive image?

How can I get the caption text on these images to move around when then the browser window is resized? My implementation is jicky and I need a way to keep the text from sliding around when the window is resized.
Codepen
<div class="row">
<div class="col-md-6">
<img src="http://placekitten.com/600/375" class="img-responsive" />
<h2 class="homeImageLink">
<span>Caption Text</span>
</h2>
</div>
<div class="col-md-6">
<img src="http://placekitten.com/600/375" class="img-responsive" />
<h2 class="homeImageLink">
<span>Caption Text</span>
</h2>
</div>
</div>
.homeImageLink {
position: absolute;
top: 110px;
left: 0;
text-align: center;
width: 100%;
}
.homeImageLink span {
color: red;
font-weight: 300;
font-style: italic;
text-transform: uppercase;
letter-spacing: 15px;
pointer-events: none;
}
Just add one class to parent container, make it's position relative.
.img-container {
position:relative;
}
And then make homeImageLink absolute and give top at around 45%..
It will make it vertically centered..
.homeImageLink {
position: absolute;
top: calc(50% - 24px); //24px is font size of H1 I assume
left: 0;
text-align: center;
width: 100%;
}
Demo here : http://codepen.io/anon/pen/bJadE
I came up with another solution, here's a working demo:
http://codepen.io/niente0/pen/jyzdRp
HTML:
<DIV class=wrapper>
<DIV class=divimage></DIV>
<DIV class=divtext>THIS IS A TEST</DIV>
</DIV>
CSS:
HTML,BODY {
max-width:1200px;
}
.wrapper {
position:relative;
width:100%;
max-width:1200px;
height:100%;
min-height:320px
}
.divimage { position:absolute;
top:0;
left:0;
width:100%;
height:100%;
background:url(https://thumbs.dreamstime.com/t/empty-red-banner-corners-ropes-textile-white-background-d-illustration-70434974.jpg);
background-repeat:no-repeat;
background-size:100% auto;
}
.divtext {
position:absolute;
top:0;
left:0;
width:100%;
padding-top:13.5%;
text-align:center;
font-weight:bold;
font-size:5vw;
color:white;
font-family:arial;
}
#media (min-width: 1200px) {
.divtext{
font-size:60px;
}
}