Center content over full screen slick slider - html

I'm trying to center content over a fullscreen slick slider (kenwheeler.github.io/slick/),
I've attempted to use a flex box but the content remains at the edge of the viewport, which appears to be an issue with the position tag of the slick css but I can't figure out what I'm doing wrong.
It's my first time working with flex so maybe I'm missing something?
Website live here
HTML
<div class="wrapper">
<div class="main">
<img class="logo" src="img/logo.png">
<h1>XXXXXX</h1>
<h2>XXXX is a collaboration between XXXX & XXXX</h2>
</div>
<div class="background">
<div class="slide" style="background: url('bg/hlg1.jpg') no-repeat center center"></div>
<div class="slide" style="background: url('bg/hlg2.jpg') no-repeat center center"></div>
<div class="slide" style="background: url('bg/hlg3.jpg') no-repeat center center"></div>
<div class="slide" style="background: url('bg/hlg4.jpg') no-repeat center center"></div>
</div>
CSS
*{
min-height: 0;
min-width: 0;
cursor: crosshair;
}
html{
height: 100%;
min-height: 100%;
}
body{
font-family: sans-serif, "Helvetica", "Arial";
font-weight: bold;
font-size: 62.5%;
color: #fff;
text-align: center;
height: 100%;
margin: 0;
padding: 0;
width: 100%;
background: #000;
min-height: 100%;
overflow: hidden;
}
.wrapper {
height: 100%;
display: flex;
align-items: center;
justify-content: center;
}
.slide {
height: 100%;
width: 100%;
background-size: cover !important;
}
.background {
height: 100%;
width: 100%;
z-index: 0;
}
.slick-list,
.slick-track {
height: 100%;
}
.slick-prev {
position: fixed;
left: 2vw;
height: 4vh;
width: 3vw;
z-index: 2;
}
.slick-next {
position: fixed;
right: 2vw;
height: 4vh;
width: 3vw;
z-index: 2;
}
.slick-slider {
margin-bottom: 0;
}
.arrow:hover {
cursor: crosshair;
}
.main {
flex: none;
top: 3vh;
z-index: 1;
max-width: 50%;
position: absolute;
}
.logo {
width: 25vw;
margin: auto;
}

Since that element (main) stays there all the time, you can use these settings:
.main {
position: fixed;
top: 50%;
left: 50%;
transform: translateX(-50%) translateY(-50%);
z-index: 1;
}

Related

Image sticks out of border

The image goes out of a white border and I want it to be inside:
body {
margin: 0px;
}
div.container {
height: 100vh;
background-image: url("https://i.imgur.com/AQI5SzX.jpeg");
background-repeat: no-repeat;
background-size: cover;
background-position: bottom;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
div.whitebox {
position: relative;
left: -5%;
width: 75%;
height: 75%;
background-color: white;
border-radius: 3%;
}
div.titleclass {
position: relative;
height: 30vh;
overflow: hidden;
}
div.overlay {
position: absolute;
background-color: #bdb76b6b;
background-image: url("https://i.imgur.com/vah2G4d.jpeg");
background-blend-mode: screen;
background-size: cover;
opacity: 0.9;
transform: rotate(7deg) translate(-2.3%, -20%);
height: 50vh;
width: 105%;
}
div.title {
font-family: "Rockwell";
font-size: 3.5vw;
text-align: left;
color: #006400;
font-weight: 400;
font-style: normal;
position: relative;
top: 25px;
left: 20px;
}
<div class="container">
<div class="whitebox">
<div class="content">
<div class="titleclass">
<div class="overlay"></div>
<div class="title">MODULO ISCRIZIONE SOFTAIR</div>
</div>
</div>
</div>
</div>
<script src="Modulo_softair_rework.js"></script>
get rid of height:75% and use top to reposition
body {
margin: 0px;
}
div.container {
height: 100vh;
background-image: url("https://i.imgur.com/AQI5SzX.jpeg");
background-repeat: no-repeat;
background-size: cover;
background-position: bottom;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
div.whitebox {
position: relative;
left: -5%;
top:-25%;
width: 75%;
background-color: white;
border-radius: 3%;
}
div.titleclass {
position: relative;
height: 30vh;
overflow: hidden;
}
div.overlay {
position: absolute;
background-color: #bdb76b6b;
background-image: url("https://i.imgur.com/vah2G4d.jpeg");
background-blend-mode: screen;
background-size: cover;
opacity: 0.9;
transform: rotate(7deg) translate(-2.3%, -20%);
height: 50vh;
width: 105%;
}
div.title {
font-family: "Rockwell";
font-size: 3.5vw;
text-align: left;
color: #006400;
font-weight: 400;
font-style: normal;
position: relative;
top: 25px;
left: 20px;
}
<div class="container">
<div class="whitebox">
<div class="content">
<div class="titleclass">
<div class="overlay"></div>
<div class="title">MODULO ISCRIZIONE SOFTAIR</div>
</div>
</div>
</div>
</div>
<script src="Modulo_softair_rework.js"></script>
Add overflow:hidden to parent div which has the border radius.
body {
margin: 0px;
}
div.container {
height: 100vh;
background-image: url("https://i.imgur.com/AQI5SzX.jpeg");
background-repeat: no-repeat;
background-size: cover;
background-position: bottom;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
div.whitebox {
position: relative;
left: -5%;
width: 75%;
height: 75%;
background-color: white;
border-radius: 3%;
/*here is the change */
/*here is the change */
/*here is the change */
overflow: hidden;
}
div.titleclass {
position: relative;
height: 30vh;
overflow: hidden;
}
div.overlay {
position: absolute;
background-color: #bdb76b6b;
background-image: url("https://i.imgur.com/vah2G4d.jpeg");
background-blend-mode: screen;
background-size: cover;
opacity: 0.9;
transform: rotate(7deg) translate(-2.3%, -20%);
height: 50vh;
width: 105%;
}
div.title {
font-family: "Rockwell";
font-size: 3.5vw;
text-align: left;
color: #006400;
font-weight: 400;
font-style: normal;
position: relative;
top: 25px;
left: 20px;
}
<div class="container">
<div class="whitebox">
<div class="content">
<div class="titleclass">
<div class="overlay"></div>
<div class="title">MODULO ISCRIZIONE SOFTAIR</div>
</div>
</div>
</div>
</div>
<script src="Modulo_softair_rework.js"></script>

Position: absolute overlapping with wide viewport

I have a slightly rotated div creating an asymetrical graphic on my start page. I use overflow: hidden to hide the overlap from that div. Everything uses absolute positioning to get the elements exactly where I want them and vw and vh to make it responsive. It looks great while the aspect ratio is "normal" but when the window approaches a 2 or 3:1 aspect ratio (like an ultrawide monitor) everything overlaps. Narrow aspect ratio is not a problem since I have it switch to mobile view before it becomes a problem.
I considered using overflow: auto so it wouldn't be forced to fit in the viewport but then it's possible to see the edges of the rotated div.
Is there a solution to this or is this perhaps bad practice and should be done differently?
html, body {
margin: 0;
padding: 0;
height: 100%;
width: 100%;
}
#body {
overflow: hidden;
background: red;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
.shape {
position: absolute;
right: -10%;
top: -50%;
height: 200%;
width: 45%;
transform: rotate(350deg);
background: white;
}
#welcome {
position: absolute;
color: black;
z-index: 999;
margin-left: 65vw;
margin-top: 10vh;
}
#welcome h1 {
margin-bottom: 0;
font-size: 7vw;
}
#welcome p {
font-size: 4vw;
margin-top: 0;
}
#startbtn {
position: absolute;
font-size: 3vw;
padding: 4vh 5.5vw 4vh 5.5vw;
background: blue;
color: white;
border: none;
margin-left: 65vw;
margin-top: 70vh;
}
<body id="body">
<div class="shape"></div>
<div class="wrapper">
<div id="welcome" autofocus>
<h1>Welcome</h1>
<p>More Text Here</p>
</div>
</div>
<div class="wrapper">
<input type="button" id="startbtn" onclick="getstarted()" value="Get Started">
</div>
</body>
</html>
Thanks!
Welcome to Stackoverflow.
Putting the shape into the same container (I used the first wrapper) as your content should fix the problem. Why is this: Because the white shape should be in relation to your content. Also I did put the button in the same container.
And you dont need background-sizes for your body as it is just plain red.
I might have messed up your original dimensions, but this should do the trick.
html,
body {
margin: 0;
padding: 0;
height: 100%;
width: 100%;
}
body {
overflow: hidden;
background: red;
}
.wrapper {
position: relative;
height: 100%;
}
.shape {
position: absolute;
margin-top: -50%;
margin-right: -50%;
right: 0;
height: 300%;
width: 100%;
transform: rotate(350deg);
background: white;
}
#welcome {
position: absolute;
color: black;
z-index: 999;
margin-left: 65vw;
margin-top: 10vh;
}
#welcome h1 {
margin-bottom: 0;
font-size: 7vw;
}
#welcome p {
font-size: 4vw;
margin-top: 0;
}
#startbtn {
position: absolute;
font-size: 3vw;
padding: 4vh 5.5vw 4vh 5.5vw;
background: blue;
color: white;
border: none;
margin-left: 65vw;
margin-top: 70vh;
}
html,
body {
margin: 0;
padding: 0;
height: 100%;
width: 100%;
}
#body {
overflow: hidden;
background: red;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
.wrapper {
position: relative;
height: 100%;
}
.shape {
position: absolute;
margin-top: -50%;
margin-right: -50%;
right: 0;
height: 300%;
width: 100%;
transform: rotate(350deg);
background: white;
}
#welcome {
position: absolute;
color: black;
z-index: 999;
margin-left: 65vw;
margin-top: 10vh;
}
#welcome h1 {
margin-bottom: 0;
font-size: 7vw;
}
#welcome p {
font-size: 4vw;
margin-top: 0;
}
#startbtn {
position: absolute;
font-size: 3vw;
padding: 4vh 5.5vw 4vh 5.5vw;
background: blue;
color: white;
border: none;
margin-left: 65vw;
margin-top: 70vh;
}
<div class="wrapper">
<div class="shape"></div>
<div id="welcome" autofocus>
<h1>Welcome</h1>
<p>More Text Here</p>
</div>
<input type="button" id="startbtn" onclick="getstarted()" value="Get Started">
</div>

Image (location pins) on top of background image

i have location pins on top of background image.
but when its responsive pins location chages.
i want set pins at specific position of images
<div class="container">
<img src="http://www.clipartbest.com/cliparts/ncX/qyL/ncXqyLdcB.png" class="pin1">
<img src="http://www.clipartbest.com/cliparts/ncX/qyL/ncXqyLdcB.png" class="pin2">
</div>
css
body {
background: url(http://connect.homes.com/wp-content/uploads/2012/05/200392710-0012.jpg) no-repeat center center fixed;
/* -webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;*/
color: white;
font-family: 'Open Sans', 'Nunito', sans-serif;
}
.pin1 {
position: absolute;
width: 30px;
height: auto;
top: 10%;
left: 28%;
}
.pin2 {
position: absolute;
width: 30px;
height: auto;
top: 40%;
left: 50%;
}
i am trying to set position but its not working
Don't use a background image as it's not responsive in the same way as positioning. Use an actual inline image in a wrapper and position your pins on that.
Here's an example:
* {
margin: 0;
padding: 0;
box-sizing: border-box;
text-align: center;
}
.map {
margin: 10px;
border: 5px solid red;
position: relative;
display: inline-block;
}
.map img {
max-width: 100%;
display: block;
}
.box {
width: 8%;
height: 8%;
background-image: url(http://www.clker.com/cliparts/W/0/g/a/W/E/map-pin-red.svg);
background-position: top center;
background-repeat: no-repeat;
background-size: contain;
position: absolute;
}
#pin-1 {
top: 29%;
left: 36%;
}
.box:hover>.pin-text {
display: block;
}
.pin-text {
position: absolute;
top: 50%;
transform: translateY(-50%);
left: 75%;
white-space: nowrap;
display: none;
}
.pin-text h3 {
color: white;
text-shadow: 1px 1px 1px #000;
}
<div class="map">
<img src="https://upload.wikimedia.org/wikipedia/commons/thumb/6/68/Pleasant_View_housing_development%2C_Missoula%2C_Montana_-_panoramio.jpg/800px-Pleasant_View_housing_development%2C_Missoula%2C_Montana_-_panoramio.jpg" alt="" />
<div id="pin-1" class="box">
<div class="pin-text">
<h3>My House</h3>
</div>
</div>
</div>

Divs are overlapping subheader

I am rather new to HTML and CSS, and have been struggling to find a solution to a problem. The problem is that .wrapper2 with text and image is overlapping .wrapper1 with subheader. Here is the fiddle https://jsfiddle.net/c85frkjd/ .
Is would really appreciate the help:)
CSS:
.totalWrapper{
width: 964px;
height: auto;
margin-bottom: 250px;
box-sizing: border-box;
padding: 0;
}
.wrapper1{
width: 964px;
height: 200px;
position: absolute;
left: 50%;
margin-left: -50%;
margin-top: -10px;
}
.shrink-wrap{
width: 100vw;
height: 100%;
top: -5%;
position: relative;
overflow: visible;
display: inline-block;
}
.subSubHeaderImage{
width: 100vw;
height: 100%;
left: 50%;
right: 50%;
margin-left: -50vw;
margin-right:-50vw;
background: url(http://localhost/wordpress/wp-
content/uploads/2017/04/sandwichmaaler.png) center no-repeat;
-webkit-background-size: cover;
-moz-background-size: cover;
-ms-background-size: cover;
-o-background-size: cover;
background-size: cover;
position: absolute;
overflow: visible;
}
.subSubHeaderImageTekst h1{
width: 100%;
top: 35px;
align-items: center;
position: absolute;
font-family: "Roboto Slab", sans-serif;
text-align: center;
font-size: 36px;
color: #fff;
z-index: ;
}
.subSubHeaderImageTekst p{
width: 100%;
position: absolute;
top: 95px;
color: #a8adb1;
line-height: 26px;
font-family: "Roboto Slab", sans-serif;
text-align: center;
font-weight: 300;
font-size: 18px;
}
.wrapper2{
width: 964px;
height: auto;
margin: 0;
padding: 30px 0;
position: absolute;
z-index: 1;
}
.kolonne1{
float: left;
width: 100%;
height: auto;
margin-top: 40px;
-webkit-column-count: 2;
-moz-column-count: 2;
column-count: 2;
-webkit-column-gap: 60px;
-moz-column-gap: 60px;
column-gap: 60px;
}
.kolonne1 img{
height: auto;
margin-top: -20px;
width: 85%;
}
HTML:
<div class="totalWrapper">
<div class="wrapper1">
<div class="shrink-wrap">
<div class="subSubHeaderImage">
</div> <!--end of .subSubHeaderImage-->
<div class="subSubHeaderImageTekst">
<h1>texttexttexttext</h1>
<p>texttexttexttextt</p>
</div> <!--end of .subSubHeaderImageTekst-->
</div> <!--end of .shrink-wrap-->
</div> <!--end of .wrapper1-->
<div class="wrapper2">
<div class="kolonne1">
texttexttexttexttexttexttext
<img src="http://localhost/wordpress/wp-
content/uploads/2017/04/burger_lille-300x200.png" alt="burger" width="350"
height="233"/>
</div> <!--end of .kolonne1-->
</div> <!--end of .wrapper2-->
<div class="push">
</div> <!--end of .push-->
</div> <!--end of .totalWrapper-->
They're both absolutely positioned and neither of them has a top. To keep them from overlapping, add position: relative to the parent, and a top value for .wrapper2 that will push it below the height of .wrapper1. Since .wrapper1 is 200px (height) - 10px (negative top margin), the top for .wrapper2 should be 190px
.totalWrapper {
width: 964px;
height: auto;
margin-bottom: 250px;
box-sizing: border-box;
padding: 0;
position: relative;
}
.wrapper1 {
width: 964px;
height: 200px;
position: absolute;
left: 50%;
margin-left: -50%;
margin-top: -10px;
}
.shrink-wrap {
width: 100vw;
height: 100%;
top: -5%;
position: relative;
overflow: visible;
display: inline-block;
}
.subSubHeaderImage {
width: 100vw;
height: 100%;
left: 50%;
right: 50%;
margin-left: -50vw;
margin-right: -50vw;
background: url(http://localhost/wordpress/wp-content/uploads/2017/04/sandwichmaaler.png) center no-repeat;
-webkit-background-size: cover;
-moz-background-size: cover;
-ms-background-size: cover;
-o-background-size: cover;
background-size: cover;
position: absolute;
overflow: visible;
}
.subSubHeaderImageTekst h1 {
width: 100%;
top: 35px;
align-items: center;
position: absolute;
font-family: "Roboto Slab", sans-serif;
text-align: center;
font-size: 36px;
color: #fff;
z-index: ;
}
.subSubHeaderImageTekst p {
width: 100%;
position: absolute;
top: 95px;
color: #a8adb1;
line-height: 26px;
font-family: "Roboto Slab", sans-serif;
text-align: center;
font-weight: 300;
font-size: 18px;
}
.wrapper2 {
width: 964px;
height: auto;
margin: 0;
padding: 30px 0;
position: absolute;
z-index: 1;
top: 190px;
}
.kolonne1 {
float: left;
width: 100%;
height: auto;
margin-top: 40px;
-webkit-column-count: 2;
-moz-column-count: 2;
column-count: 2;
-webkit-column-gap: 60px;
-moz-column-gap: 60px;
column-gap: 60px;
}
.kolonne1 img {
height: auto;
margin-top: -20px;
width: 85%;
}
<div class="totalWrapper">
<div class="wrapper1">
<div class="shrink-wrap">
<div class="subSubHeaderImage">
</div>
<!--end of .subSubHeaderImage-->
<div class="subSubHeaderImageTekst">
<h1>texttexttexttext</h1>
<p>texttexttexttextt</p>
</div>
<!--end of .subSubHeaderImageTekst-->
</div>
<!--end of .shrink-wrap-->
</div>
<!--end of .wrapper1-->
<div class="wrapper2">
<div class="kolonne1">
texttexttexttexttexttexttext
<img src="http://localhost/wordpress/wp-content/uploads/2017/04/burger_lille-300x200.png" alt="burger" width="350" height="233" />
</div>
<!--end of .kolonne1-->
</div>
<!--end of .wrapper2-->
<div class="push">
</div>
<!--end of .push-->
</div>
<!--end of .totalWrapper-->
Since you are positioning .wrapper-1 and .wrapper-2 absolutely, this means you are essentially setting two pieces of paper directly on top of each other in a stack, so they can equally cover each other. If you position them relatively, then it would be like laying each piece of paper side by side on a flat surface. You could move the pieces around so one is above another, but they wouldn't overlap or cover each other unless you added some extra code. They would be positioned around each other. You could say, this piece is beside the other piece, or above or below, but not directly on top of or under. So to fix your issue, you need to change them to be positioned relatively.

Responsive logo placement

I am trying to figure out how to place the logo in the middle of the two sections of my landing page but only on the mobile view. The text class is for my logo. I cant seem to figure out the best way to do so.
.text {
position: absolute;
right: 70px;
left: 70px;
text-align: center;
z-index: 10;
margin: auto;
max-width: 600px;
}
Here is the codepen: http://codepen.io/anon/pen/xqQPVN?editors=1100
Just give it position:absolute and set it accordingly for mobile devies..
Added the following css in the case of mobile.
/* Logo In Center For Mobile Device*/
.logo-big {
display: block;
width: 100%;
position: absolute;
top: 500px;
margin-top: -75px;
}
Codepen link-http://codepen.io/sahildhir_1/pen/wJQxQy?editors=1100
Below is the snippet-
* {
box-sizing: border-box;
}
html,
body {
height: 100%
}
img {
max-width: 100%;
}
.item {
width: 50%;
float: left;
top: 0;
left: 0;
height: 100%;
z-index: 0;
overflow: hidden;
background-color: #000000;
background-position: center center;
background-size: auto 100%;
position: relative;
}
.overlay {
width: 100%;
height: 100%;
position: absolute;
background-color: rgba(0, 0, 0, 0.3);
transition: .2s linear;
}
.nurseryarea {
width: 100%;
position: absolute;
text-align: center;
top: 45%;
color: #fff;
font-size: 30px;
font-family: 'times new roman';
font-weight: bold;
transition: .2s linear;
}
::selection {
color: #ebebe3;
background: #222;
}
::-moz-selection {
color: #ebebe3;
background: #222;
}
.overlay:hover {
background-color: rgba(0, 0, 0, 0.1);
transition-property: background-color;
}
.overlay:hover .nurseryarea {
opacity: 1;
transition-property: opacity;
}
.logo-big {
display: block;
width: 100%;
}
.logo-big .svg {
display: block;
width: 100%;
height: auto;
}
.imgsize {
width: 40%;
}
.text {
position: absolute;
right: 70px;
left: 70px;
text-align: center;
z-index: 10;
margin: auto;
max-width: 600px;
}
#media screen and (max-width:600px) {
.nurseryarea {
width: 100%;
}
.imgsize {
width: 60%;
}
.text {
position: absolute;
right: 70px;
left: 70px;
text-align: center;
z-index: 10;
margin: auto;
max-width: 600px;
}
/* Logo In Center For Mobile Device*/
.logo-big {
display: block;
width: 100%;
position: absolute;
top: 500px;
margin-top: -75px;
}
.logo-big .svg {
display: block;
width: 100%;
height: auto;
}
.item {
width: 100%;
float: left;
top: 0;
left: 0;
height: 500px;
z-index: 0;
overflow: hidden;
background-color: #000000;
background-position: center center;
background-size: auto 100%;
}
}
<div class="text">
<a class="logo logo-big" href="http://www.lygonstnursery.com">
<img class="svg " src="https://www.lygonstnursery.com/wp-content/uploads/2017/03/NURSERY-landing-page.png" alt="Lygon Street Nursery">
</a>
</div>
<div class="item" style="background-image: url(https://www.lygonstnursery.com/wp-content/uploads/2017/02/LygonStNursery_Nursery-29.jpg);background-size:cover;">
<div class="overlay">
<div class="nurseryarea">
<img class='imgsize' src="https://www.lygonstnursery.com/wp-content/uploads/2017/03/nursery.png" ;>
</div>
</div>
</div>
<div class="item" style="background-image: url(https://www.lygonstnursery.com/wp-content/uploads/2017/02/LygonStNursery_Brunswick-24.jpg); background-size:cover;">
<div class="overlay">
<div class="nurseryarea">
<img class="imgsize" src="https://www.lygonstnursery.com/wp-content/uploads/2017/03/landscapes.png" ;>
</div>
</div>
</div>
If you want to have total control over the positioning i'd say go for progressively specific media queries (say: 425px, 375px, 320px) and use pixel positioning.
If you want to keep it generic, you must be prepared to have some small differences between these sizes, but you can use percentages and the result isn't so bad.
#media (max-width: 425px) {
.text {
position: absolute;
right: 34%;
left: 32%;
top: 34%;
}
}