I am having some difficulty getting slanted images to fit within 100% of my viewport width. Specifically,
div two-images-outer and two-images-inner are currently outside the 100% width of the viewport. I want to get it in line with the rest of the sections below (see image). Any help is greatly appreciated!
Image to illustrate problem of image div extending beyond 100% width of the viewport the image div is extending in order to obtain the skewed slant:
HTML:
<section>
<div class="three-images-wrapper">
<div class="three-images">
<div class="featured-image-outer">
<div class="featured-image-inner"
style="background-image: url(../img/servicesheader1.jpeg);">
<h1>Services</h1>
</div>
</div>
<div class="two-images">
<div class="two-images-outer">
<div class="two-images-inner">
<div class="image1"
style="background-image: url('../img/servicesheader2.jpeg');">
</div>
</div>
</div>
</div>
</div>
</div>
</section>
CSS:
.three-images-wrapper {
height: 300px;
width: 100%;
}
.three-images {
margin-bottom: 4rem;
min-height: 300px;
position: relative;
}
.featured-image-outer {
position: absolute;
margin-left: -15%;
min-height: 360px;
overflow: hidden;
width: 76.5%;
-ms-transform: skew(-15deg,0deg); /* IE 9 */
-webkit-transform: skew(-15deg,0deg); /* Safari */
transform: skew(-15deg,0deg); /* Standard syntax */
}
.featured-image-inner,
.two-images-inner {
background-size: cover;
background-position: center;
}
.featured-image-inner {
left: 50px;
position: absolute;
top: 0;
height: 300px;
width: 100%;
-ms-transform: skew(15deg,0deg); /* IE 9 */
-webkit-transform: skew(15deg,0deg); /* Safari */
transform: skew(15deg,0deg); /* Standard syntax */
}
.two-images {
min-height: 300px;
position: relative;
right: -63vw;
top: 0;
width: 55%;
}
.two-images-outer {
min-height: 130px;
overflow: hidden;
position: absolute;
width: 100%;
-ms-transform: skew(-15deg,0deg); /* IE 9 */
-webkit-transform: skew(-15deg,0deg); /* Safari */
transform: skew(-15deg,0deg); /* Standard syntax */
}
.two-images-inner {
-ms-transform: skew(15deg,0deg); /* IE 9 */
-webkit-transform: skew(15deg,0deg); /* Safari */
transform: skew(15deg,0deg); /* Standard syntax */
}
.image1
{
position: relative;
height: 300px;
right: 19%;
width: 100%;
background-position: center;
background-size: cover;
background-clip: content-box;
}
You can use clip-path and it will be easier
.container {
height: 300px;
display:flex;
}
.container > * {
background-position: center;
background-size: cover;
flex:1;
}
.container > :first-child {
clip-path:polygon(0 0,100% 0,calc(100% - 100px) 100%,0 100%);
margin-right:-40px;
}
.container > :last-child {
clip-path:polygon(100px 0,100% 0,100% 100%,0 100%);
margin-left:-40px;
}
<div class="container">
<div style="background-image: url(https://picsum.photos/id/10/800/800);">
<h1>Services</h1>
</div>
<div style="background-image: url(https://picsum.photos/id/14/800/800);">
</div>
</div>
Related
I implemented css animation to the image and it works well on explorer or chrome through the pc.
Though, on safari, the image is placed in the left top corner. Since I'm using position: absolute and relative for animation, I can't use display:flex option.
Plus, as you can see from below ss, card size is also not fit as applied in css, and have weird space between card and buttons.
current status on safari
Here is my current code:
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
img {
vertical-align: middle;
}
.container {
width: 100%;
height: 100vh;
overflow: hidden;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
background-image: url("../../images/background-forloading.jpg");
background-repeat: no-repeat;
background-position: center;
background-size: cover;
}
.flip-card {
width: 100%;
height: 80vh;
perspective: 1600px;
cursor: pointer;
transform: translateY(40px) rotateX(-8deg) rotateY(10deg);
animation: movement 5s infinite;
}
#keyframes movement {
50% {
transform: translateY(-40px) rotateX(8deg) rotateY(-10deg);
}
}
.flip-card div {
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
backface-visibility: hidden;
transition: 0.7s;
width: 100vw;
height: 80vh;
}
.flip-card div img {
width: 100vw;
height: 80vh;
object-fit: contain;
}
.front {
filter: drop-shadow(0 0 30px #000);
}
.back {
transform: rotateY(180deg);
}
.flip-card:hover .front {
transform: rotateY(-180deg);
}
.flip-card:hover .back {
transform: rotateY(0);
filter: drop-shadow(0 0 20px rgb(120, 185, 232));
}
<div class="container">
<div class="flip-card">
<div class="front">
<img src="images/귀문관카드뒤.png">
</div>
<div class="back">
<img src="images/인간.png">
</div>
</div>
<div class="flip-card-button text-center">
<button class="enter">Save</button>
<button type="submit" class="enter">Next</button>
</div>
</div>
I'm not sure if it solves your problem, but your code is currently missing the browser prefixes.
-webkit- for Chrome, Safari, Opera, iOS
-moz- Firefox
-ms- Internet Explorer and Edge
I have created a template which have the page divided in two sections, when I display the site in a desktop resolution all works well, but when I run the site on a smartphone I get the half circle on top and the divider between the two images, not responsive:
Essentially the half red circle, should be reduced in a smartphone resolution, and the divider goes outside the two images, this is what I tried so far:
#media (max-width: 800px) {
.divider{
top: 14.5%;
left: 50%;
height: 64.2%;
transform: translateX(-50%);
}
.circle{
top: -45%;
left: 50%;
width: 500px;
height: 400px;
border-radius: 50%;
}
.logo{
top: 0.5%;
left: 22.5%;
}
}
the problem's that this doesn't cover all the resolution case, so the problem is not fixed at all.
Is there a way to handle all the resolutions and make that template really responsive?
This is my fiddle.
SNIPPET:
body {
background-color: #ffffff;
}
/*Overlay*/
.hovereffect {
width: 50%;
height: 90vh;
float: left;
overflow: hidden;
position: relative;
text-align: center;
cursor: default;
background: #a7151f;
}
.hovereffect .overlay {
width: 100%;
height: 100%;
position: absolute;
overflow: hidden;
top: 0;
left: 0;
padding: 50px 20px;
justify-content: center;
flex-direction: column;
display: flex;
}
.hovereffect img {
float: left;
width: 50%;
height: 90vh;
display: block;
position: relative;
max-width: none;
width: calc(100% + 20px);
-webkit-transition: opacity 0.35s, -webkit-transform 0.35s;
transition: opacity 0.35s, transform 0.35s;
-webkit-transform: translate3d(-10px, 0, 0);
transform: translate3d(-10px, 0, 0);
-webkit-backface-visibility: hidden;
backface-visibility: hidden;
}
.hovereffect:hover img {
opacity: 0.4;
filter: alpha(opacity=40);
-webkit-transform: translate3d(0, 0, 0);
transform: translate3d(0, 0, 0);
}
.hovereffect h2 {
text-transform: uppercase;
color: #fff;
text-align: center;
position: relative;
font-size: 40px;
overflow: hidden;
padding: 0.5em 0;
background-color: transparent;
opacity: 0;
filter: alpha(opacity=0);
}
.hovereffect h2:after {
position: absolute;
bottom: 0;
left: 0;
width: 100%;
height: 2px;
background: #fff;
content: '';
-webkit-transition: -webkit-transform 0.35s;
transition: transform 0.35s;
-webkit-transform: translate3d(-100%, 0, 0);
transform: translate3d(-100%, 0, 0);
}
.hovereffect:hover h2:after {
-webkit-transform: translate3d(0, 0, 0);
transform: translate3d(0, 0, 0);
}
.hovereffect a,
.hovereffect p {
color: #FFF;
opacity: 0;
filter: alpha(opacity=0);
-webkit-transition: opacity 0.35s, -webkit-transform 0.35s;
transition: opacity 0.35s, transform 0.35s;
-webkit-transform: translate3d(100%, 0, 0);
transform: translate3d(100%, 0, 0);
}
.hovereffect:hover a,
.hovereffect:hover p,
.hovereffect:hover h2 {
opacity: 1;
filter: alpha(opacity=100);
-webkit-transform: translate3d(0, 0, 0);
transform: translate3d(0, 0, 0);
font-size: 16px;
}
/*DIVISORE*/
.middle {
position: absolute;
z-index: 9999;
}
.divider {
border-right: 5px solid #a7151f;
position: absolute;
z-index: 10;
top: 14.5%;
left: 50%;
margin: 0;
padding: 0;
width: auto;
height: 76.2%;
line-height: 0;
text-align: center;
text-transform: uppercase;
transform: translateX(-50%);
}
.circle {
z-index: 10;
position: absolute;
top: -250px;
left: 50%;
border: 5px solid #a7151f;
margin: 0;
padding: 0;
height: 100%;
line-height: 0;
text-align: center;
text-transform: uppercase;
transform: translateX(-50%);
background-color: #a7151f;
width: 500px;
height: 400px;
border-radius: 50%;
}
.first {
background-image: url('https://demos.creative-tim.com/material-kit-pro/assets/img/dg1.jpg');
background-size: cover;
background-position: center;
background-repeat: no-repeat;
}
.second {
background-image: url('https://demos.creative-tim.com/material-kit-pro/assets/img/bg9.jpg');
background-size: cover;
background-position: center;
background-repeat: no-repeat;
}
.logo {
top: 2.5%;
position: absolute;
left: 41.5%;
width: 200px;
margin: 0 auto;
}
<link href="https://demos.creative-tim.com/material-kit-pro/assets/css/material-kit.min.css" rel="stylesheet"/>
<!DOCTYPE html>
<html lang="en">
<head>
<title>
Site
</title>
</head>
<body class="sections-page sidebar-collapse">
<div class="main">
<div class="container-fluid">
<div class="row">
<div class="hovereffect">
<img class="first">
<div class="overlay">
<h2>First</h2>
<p>
Explore
</p>
</div>
</div>
<span class="divider"></span>
<img class="img-responsive center-block circle">
<span class="circle">
</span>
<img src="#" class="logo" style="z-index: 9999">
<div class="hovereffect">
<img class="second">
<div class="overlay">
<h2>Second</h2>
<p>
Explore
</p>
</div>
</div>
</div>
</div>
<footer class="footer">
<div class="container">
<div class="row align-items-center justify-content-xl-between">
<div class="col-6">
<div class="copyright text-center text-xl-left text-muted">
© 2019 Credit
</div>
</div>
<div class="col-6">
<div class="row">
Privacy Policy
Terms & Conditions
</div>
</div>
</div>
</div>
</footer>
</div>
</body>
</html>
This kind of layout can be achieved with Flexbox with many fewer lines of code. Also, much less HTML markup is required.
Total responsiveness is achieved combining the flexbox behavior with relative units (%, vh, vw).
I put several comments in the CSS to explain what each rule is doing.
body { margin: 0; }
.the-container {
position: relative;
overflow: hidden;
height: 100vh; /* fill the screen */
width: 100vw; /* fill the screen */
}
.the-circle {
position: absolute; /* overlap the pics, removes it from the box flow */
background-color: #a7151f;
border-radius: 50%; /* rectangle becomes an ellipse */
width: 60vw;
height: 30vh;
top: -15vh; /* half of the height */
left: 0; /* these 3 lines... */
right: 0; /* ...keep the "circle"... */
margin: auto; /* ...centered at the top */
}
.the-image-wrapper {
display: flex; /* easy responsive columns */
height: 100%; /* fill the screen */
}
.the-image-wrapper > div {
flex: 1 0 auto; /* items inside the wrapper will grow to fit avilable space */
}
.the-image-wrapper > div.the-divider {
flex: 0 1 5px; /* this divider item will not grow, and will be 5px wide */
background-color: #a7151f;
}
.first {
background-image: url('https://demos.creative-tim.com/material-kit-pro/assets/img/dg1.jpg');
background-size: cover;
background-position: center;
background-repeat: no-repeat;
}
.second {
background-image: url('https://demos.creative-tim.com/material-kit-pro/assets/img/bg9.jpg');
background-size: cover;
background-position: center;
background-repeat: no-repeat;
}
<div class="the-container">
<div class="the-circle"></div>
<div class="the-image-wrapper">
<div class="first"></div>
<div class="the-divider"></div>
<div class="second"></div>
</div>
</div>
I'm trying to create a parallax background as a separator for a site. The background image seems to be only taking up about half of the size it should be with a strange white border all around it. I can't seem to find anything in my code that might be causing this and no matter what I do I either have the border, or scroll bars on the inside div. I just need the background image to fit the space of the div to make a scrolling parallax in that section.
I've tried overflow:hidden playing with various height/width combinations including calc(100vh * 2) to make the image larger. The only thing it seems to do is change the image in the container it appears in (almost like a sub container but there isn't a sub-container on it). I've also played with the transform, transform-origin, perspective, scale, and anything else I could find on google and here.
html, body {
height: 100%!important;
margin: 0px;
padding: 0px;
}
input, select, textarea {
box-shadow: inset 0 2px 4px hsla(0, 0%, 0%, 0.13);
}
.ico {
width: 50px!important;
height: 50px!important;
}
nav {
position: fixed!important;
z-index: 999;
width: 100vw;
}
.content_head {
background-color: aqua;
}
.content_about {
background-color: blueviolet;
}
.content_spacer {
opacity: 0;
height: 50vh;
}
.back_spacer {
opacity: 0;
}
.back1 {
background-image: url("images/IMG_1164.JPG");
background-clip: border-box;
background-size: cover;
height: 100%!important;
width: 100%!important;
min-height: 100%!important;
min-width: 100%!important;
}
.back-group {
max-height: 75vh!important;
}
.container-fluid {
padding: 0!important;
}
/* Parallax Styles Credit to: https://keithclark.co.uk/articles/pure-css-parallax-websites */
.parallax {
perspective: 1px;
height: 100vh;
overflow-x: hidden;
overflow-y: auto;
}
.parallax__layer {
position: absolute;
transform-origin-x: 100%;
top: 0;
right: 0;
bottom: 0;
left: 0;
}
.parallax__layer--base {
transform: translateZ(0);
height: 100vh;
}
.parallax__layer--back {
position: absolute;
width: 30%!important;
height: 50vh!important;
top: 0;
right: 0;
bottom: 0;
left: auto;
margin: 0;
transform: translateZ(-1px);
-webkit-transform-origin-y: 100% 100% 0px;
-moz-transform-origin: 100% 100% 0px;
-ms-transform-origin: 100% 100% 0px;
transform-origin: 100% 100% 0px;
}
.parallax__group {
position: relative;
height: 100vh;
transform-style: preserve-3d;
overflow: auto!important;
}
<div class="parallax">
<div class="parallax__group">
<div class="parallax__layer--base content_head">
<h1 class="text-center my-auto">Content base</h1>
</div>
</div>
<div class="parallax__group back-group">
<div class="parallax__layer--back back1"></div>
<div class="parallax__layer--base content_spacer"></div>
</div>
<div class="parallax__group">
<div class="parallax__layer--base content_about">
<h1 class="text-center my-auto">Content base 2</h1>
</div>
</div>
<div class="parallax__group">
<div class="parallax__layer--back back">
<div class="parallax__layer--base content_spacer"></div>
<img src="images/IMG_1170.JPG" height="4096" width="3072" class="img-fluid"/>
</div>
</div>
</div>
Strictly speaking, I suppose it isn't actually a border, but more that the background image is smaller than the DIV element as a whole.
body,
html {
margin: 0;
padding: 0;
}
.wrapper {
height: 100vh;
overflow-x: hidden;
overflow-y: auto;
perspective: 2px;
}
.section {
position: relative;
height: 100vh;
display: flex;
align-items: center;
justify-content: center;
color: white;
text-shadow: 0 0 5px #000;
}
.parallax::after {
/* Display and position the pseudo-element */
content: " ";
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
transform: translateZ(-1px) scale(1.5);
background-size: 100%;
z-index: -1;
}
.static {
background: red;
}
.bg1::after {
background-image: url('https://images.unsplash.com/photo-1567170578400-9d182981f2a1?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=750&q=80');
}
.bg2::after {
background-image: url('https://images.unsplash.com/photo-1567170566770-eea3bb0b16ed?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=750&q=80');
}
<main class="wrapper">
<section class="section static">
<h1>Static</h1>
</section>
<section class="section parallax bg1">
<h1>Parallax</h1>
</section>
<section class="section static">
<h1>Static</h1>
</section>
<section class="section parallax bg2">
<h1>Parallax</h1>
</section>
<section class="section static">
<h1>Static</h1>
</section>
</main>
Attached is a brief mockup of what I need to create. The div not only needs to skew on the bottom, but the next row will need to skew to the top.
Is there a clean way this can be done using CSS? I've tried some CSS solutions ( e.g http://jsfiddle.net/mXLgF/ ) but can not get this effect.
My current HTML / CSS is at this stage:
<div class="skew_bottom_right">
<div style="height: 300px; background: url('http://placehold.it/850x350');">
</div>
</div>
.skew_bottom_right div:after {
content: '';
position: absolute;
left: 0;
bottom: -60px;
width: 100%;
height: 115px;
background: white;
-webkit-transform: skewY(8.5deg);
-moz-transform: skewY(8.5deg);
-ms-transform: skewY(8.5deg);
-o-transform: skewY(8.5deg);
transform: skewY(8.5deg);
-webkit-backface-visibility: hidden;
z-index: 5;
}
Each of those containers will eventually made into a slide, so ideally they should be div's with background images or containing divs having a background image.
Your code is pretty good.
Just needed some minor adjustments...
.container{
overflow:hidden;
}
.parallelogram {
width: 600px;
height: 100px;
margin: 30px 0;
transform: skewY(5deg);
background: gray;
overflow:hidden;
position:relative;
}
.parallelogram.header {
height: 150px;
margin: -30px 0;
}
.parallelogram.footer {
height: 150px;
margin: -30px 0;
}
.image{
background: url(http://placekitten.com/300/300);
background: blue;
width: calc(100% / 3);
height: 100%;
display: inline-block;
float: left;
border: 3px solid white;
box-sizing: border-box;
}
<div class="container">
<div class="parallelogram header"></div>
<div class="parallelogram">
<div class="image"></div>
<div class="image"></div>
<div class="image"></div>
</div>
<div class="parallelogram footer"></div>
</div>
I have a number of divs generated with different heights in %. I want the divs to stand on the bottom line of the black container. How can I do this? If I make them absolute positioned with bottom: 0, they will overlap each other.
This is the sort of thing flexbox was developed for if you can afford to ignore IE9 and below...
HTML
<div class="container">
<div class="box">50%</div>
<div class="box">25%</div>
<div class="box">25%</div>
</div>
CSS
.container {
height: 100vh;
background: #000;
display: flex;
align-items: flex-end;
}
.box {
height: 25%;
width: 10em;
margin-right: 1em;
background-color: red;
}
.box:first-child {
height: 50%;
}
I only know one way at the moment and it involves flipping things vertically: http://jsfiddle.net/86c9gbvu/
It's based on using CSS transforms (which is supported).
#container {
width: 500px;
height: 500px;
background: black;
-moz-transform: scaleY(-1);
-webkit-transform: scaleY(-1);
-o-transform: scaleY(-1);
transform: scaleY(-1);
-ms-filter: flipv; /*IE*/
filter: flipv;
}
#bar-one {
width: 50px;
height: 50%;
background: red;
display: inline-block;
-moz-transform: scaleY(-1);
-webkit-transform: scaleY(-1);
-o-transform: scaleY(-1);
transform: scaleY(-1);
-ms-filter: flipv; /*IE*/
filter: flipv;
}
#bar-two {
width: 50px;
height: 25%;
background: red;
display: inline-block;
-moz-transform: scaleY(-1);
-webkit-transform: scaleY(-1);
-o-transform: scaleY(-1);
transform: scaleY(-1);
-ms-filter: flipv; /*IE*/
filter: flipv;
}
#bar-three {
width: 50px;
height: 25%;
background: red;
display: inline-block;
-moz-transform: scaleY(-1);
-webkit-transform: scaleY(-1);
-o-transform: scaleY(-1);
transform: scaleY(-1);
-ms-filter: flipv; /*IE*/
filter: flipv;
}
<div id="container">
<div id="bar-one">50%</div>
<div id="bar-two">25%</div>
<div id="bar-three">25%</div>
</div>
Depending on your particular situation, you may probably work around this issue with margin-top and vertical-align, see this jsfiddle. Important is that the sum of margin-top and height should sum up to 100%.
HTML:
<div class="container">
<div class="first">f</div>
<div class="second">s</div>
<div class="third">t</div>
</div>
CSS:
.container {
width: 200px;
height: 200px;
background-color: black;
}
.first, .second, .third {
display: inline-block;
width: 50px;
background-color: red;
vertical-align: bottom;
}
.first {
height: 75%;
margin-top: 25%;
}
.second {
height: 50%;
}
.third {
height: 25%;
}
HTML:
<div class="wrap">
<div class="bars one">one</div>
<div class="bars two">two</div>
<div class="bars three">three</div>
</div>
CSS:
html
{
height: 100%;
}
body
{
margin: 0;
background: #000;
height: 100%;
}
.wrap
{
width: 40%;
position: absolute;
bottom: 0;
left: 0;
height: 100%;
}
.bars
{
width: 10%;
position: absolute;
bottom: 0;
background: red;
}
.one
{
height: 50%;
left: 0;
}
.two
{
left: 15%;
}
.three
{
left: 30%;
}
.two, .three
{
height: 25%;
}
fiddle: http://jsfiddle.net/pj7knkup/5/
no css3 (full browsers support).
One Simple solution is just transform(rotate) the wrapper div 180 deg and set all inner divs to float right.
css:
.wrapper-div{
float: right;
position: relative;
transform: rotate(180deg);
}