margin auto isn't centering flex item [duplicate] - css

This question already has an answer here:
Proper use of flex properties when nesting flex containers
(1 answer)
Closed 3 years ago.
I'm trying to center the text area in my contact section at a max-width of 1400px; at this width I change the textarea's width from 100% to 90%. The contact section lies at the bottom of the page in the footer. The text area is a flex-item and was being centered with align-items: center but when I change the width to 90% it scoots over to the left? I tried margin left/right: auto; What's going on?
https://jsfiddle.net/yat5ncmk/9/
p.s the media query is at the bottom of the CSS
html,
body {
margin: 0;
padding: 0;
box-sizing: border-box;
}
.b1,
.b2,
.b3 {
width: 70px;
height: 8.5px;
border-radius: 5px;
background-color: #fff;
margin-bottom: 10px;
transition: all .15s ease;
}
.b1 {
background-color: #56ff47;
}
.b3 {
background-color: #ff4c4c;
}
a:hover {
color: #007001;
}
.info-wrap {
flex-basis: 60%;
}
.info {
font-family: 'Cedarville Cursive';
color: white;
font-weight: bold;
font-size: 4.5rem;
text-align: center;
margin-top: 60px;
}
.arrow-right {
width: 0;
height: 0;
border-top: 30px solid transparent;
border-bottom: 30px solid transparent;
border-left: 60px solid green;
position: relative;
top: -10px;
}
.arrow-left {
width: 0;
height: 0;
border-top: 30px solid transparent;
border-bottom: 30px solid transparent;
border-right: 60px solid limegreen;
position: relative;
top: 20px;
}
.arrow-top {
width: 0;
height: 0;
border-top: 30px solid transparent;
border-bottom: 30px solid transparent;
border-left: 60px solid #20a04b;
position: relative;
top: -100px;
left: 60px;
}
.top-middle {
position: relative;
top: -110px;
}
.bottom-middle .arrow-left {
top: -40px;
}
.bottom-middle .move {
top: -70px;
}
.bottom {
position: relative;
top: -48px;
}
.bottom .arrow-left {
top: -40px;
}
/*---------------FOOTER---------------*/
.contact-section-background {
background-color: #666;
height: 300px;
clip-path: polygon(0% 0%, 10% 30%, 90% 30%, 100% 0%, 100% 100%, 0% 100%);
margin-top: -100px;
}
.contact-section {
display: flex;
background-color: #595959;
margin-top: -225px;
position: relative;
padding-bottom: 18px;
z-index: 1;
}
.contact,
.location {
flex-basis: 50%;
display: flex;
flex-direction: column;
align-items: center;
}
.contact h1,
.location h1 {
margin: 0;
font-family: 'Cedarville Cursive';
color: white;
font-size: 7rem;
}
.hex {
-webkit-clip-path: polygon(25% 60%, 75% 60%, 100% 100%, 0% 100%);
background-color: #17a832;
transform: rotate(180deg);
width: 300px;
height: 150px;
margin: 0 auto;
position: absolute;
top: 0;
right: 0;
left: 0;
bottom: 0;
z-index: 2;
}
.rhombus {
-webkit-clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
background-color: #17a832;
width: 80px;
height: 80px;
position: absolute;
margin: 0 auto;
top: 60px;
right: 0;
left: 0;
bottom: 0;
z-index: 2;
}
.back-to-top {
color: #595959;
font-size: 2.5rem;
left: -45px;
position: relative;
transform: rotate(180deg);
top: 110px;
font-family: 'Josefin Sans';
}
.btp-arrow {
color: #595959;
font-size: 3rem;
position: absolute;
left: 50%;
margin-left: -24px;
bottom: 35px;
transition: all .2s ease;
}
.btp-arrow:hover {
color: #ddae1a;
cursor: pointer;
transform: scale(1.1);
}
.contact p {
font-family: 'Josefin Sans';
font-size: 2rem;
margin-top: 0;
margin-bottom: 10px;
color: white;
}
.textarea {
position: relative;
min-width: 500px;
}
.contact textarea {
resize: none;
width: 100%;
color: #595959;
margin: 10px;
min-height: 150px;
font-family: 'Josefin Sans';
font-size: 1.5rem;
padding: 5px;
outline: none;
border: none;
background: #474646;
border-radius: 4px;
}
.contact button {
font-size: 1.5rem;
font-family: 'Josefin Sans';
background: darkgrey;
color: #595959;
padding: 4px;
padding-right: 6px;
padding-left: 6px;
border: none;
border-radius: 4px;
cursor: pointer;
position: absolute;
bottom: 10px;
right: -20px;
transition: all .4s ease;
}
.contact button:hover {
color: #ddae1a;
}
.contact-line {
margin-top: 170px;
margin-bottom: 30px;
width: 5px;
border-radius: 3px;
height: 350px;
background: #ddae1a;
position: relative;
}
.links {
display: flex;
position: relative;
max-width: 400px;
top: -5px;
left: 7px;
}
.links i {
font-size: 2.5rem;
margin-right: 15px;
}
.links p {
font-size: 1.5rem;
margin-right: 30px;
margin-top: 8px;
}
#facebook {
color: #3b64ed;
cursor: pointer;
}
#twitter {
color: #5effeb;
cursor: pointer;
}
#yelp {
color: red;
cursor: pointer;
}
.contact-design-wrap-left {
position: absolute;
left: 0;
top: 40px;
max-height: 500px;
}
.contact-design-wrap-right {
position: absolute;
bottom: 55px;
right: 0;
transform: rotate(180deg);
}
.contact-design-wrap-left .bottom {
height: 0;
}
#align {
position: absolute;
left: 70px;
top: -15px;
}
#align2 {
position: absolute;
left: 68px;
top: -5px;
}
.grey {
border-left: 60px solid #666;
}
.light-grey {
border-right: 60px solid #848484;
}
.same {
border-left: 60px solid #848484;
}
.lighter {
border-right: 60px solid #a8a3a3;
}
.map {
position: relative;
top: 50px;
}
.map i {
position: absolute;
color: #ddae1a;
font-size: 4rem;
left: 50%;
margin-left: -24px;
}
.location .map .street-1 {
width: 300px;
position: relative;
top: 95px;
left: 170px;
height: 15px;
transform: rotate(90deg);
background-color: #848484;
border-radius: 5px;
}
.location .map .street-2 {
width: 300px;
position: relative;
top: 80px;
left: -170px;
height: 15px;
transform: rotate(90deg);
background-color: #848484;
border-radius: 5px;
}
.location .map .street-3 {
margin-top: 40px;
width: 190%;
position: relative;
top: 30px;
left: -140px;
height: 18px;
background-color: #848484;
border-radius: 8px;
}
.street-info {
color: white;
position: absolute;
font-family: 'Josefin Sans';
font-size: 1.2rem;
left: 20px;
padding-top: 3px;
}
.address {
position: absolute;
left: 50%;
top: 75px;
margin-left: -68.5px;
color: #ddae1a;
text-decoration: none;
font-family: 'Josefin Sans';
font-size: 1.2rem;
text-align: center;
}
.address:hover {
color: #ddae1a;
text-decoration: underline;
}
.copyright {
position: absolute;
bottom: 0;
left: 50%;
font-family: 'Josefin Sans';
color: #a8a3a3;
font-size: 1.8rem;
padding-bottom: 5px;
margin: 0 0 0 -253.89px;
}
/*----FOOTER----*/
#media screen and (max-width: 1700px) {
#align {
position: absolute;
left: 60px;
top: -10px;
}
#align2 {
position: absolute;
left: 58px;
top: 0px;
}
.contact-design-wrap-right {
position: absolute;
bottom: 40px;
right: 0;
transform: rotate(180deg);
}
.contact h1,
.location h1 {
font-size: 6rem;
height: 160px;
}
.contact p {
font-size: 1.5rem;
}
.contact-line {
margin-top: 160px;
margin-bottom: 30px;
width: 5px;
border-radius: 3px;
height: 270px;
background: #ddae1a;
position: relative;
}
.copyright {
position: absolute;
bottom: 0;
left: 50%;
font-family: 'Josefin Sans';
color: #a8a3a3;
font-size: 1.5rem;
padding-bottom: 5px;
margin: 0 0 0 -211.99px;
}
.contact textarea {
margin-top: 0;
}
.location .map .street-2 {
width: 280px;
position: relative;
top: 60px;
left: -170px;
height: 15px;
transform: rotate(90deg);
background-color: #848484;
border-radius: 5px;
}
.location .map .street-1 {
width: 280px;
position: relative;
top: 75px;
left: 170px;
height: 15px;
transform: rotate(90deg);
background-color: #848484;
border-radius: 5px;
}
.grey {
border-left: 50px solid #666;
}
.light-grey {
border-right: 50px solid #848484;
}
.same {
border-left: 50px solid #848484;
}
.lighter {
border-right: 50px solid #a8a3a3;
}
}
#media screen and (max-width: 1450px) {
.contact button {
bottom: 15px;
}
.links {
left: 10px;
}
}
#media screen and (max-width: 1400px) {
.links {
left: 40px;
}
.contact textarea {
width: 90%;
/*None of these work?
margin-left: auto;
margin-right: auto;
align-self: center;*/
}
}
<link href="https://fonts.googleapis.com/css?family=Cedarville+Cursive|Josefin+Sans|Kumar+One+Outline|Staatliches" rel="stylesheet">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.8.2/css/all.css" integrity="sha384-oS3vJWv+0UjzBfQzYUhtDYW+Pj2yciDJxpsK1OYPAYjqT085Qq/1cq5FLXAZQ7Ay" crossorigin="anonymous">
<footer>
<div class="contact-section-background">
</div>
<div class="contact-section">
<div class="contact-design-wrap-left">
<div class="top">
<div class="arrow-left lighter" id="align"></div>
<div class="arrow-left light-grey"></div>
<div class="arrow-right grey"></div>
<div class="arrow-top same"></div>
</div>
<div class="top-middle">
<div class="arrow-left light-grey"></div>
<div class="arrow-right grey"></div>
</div>
<div class="bottom-middle">
<div class="arrow-right grey"></div>
<div class="arrow-left light-grey"></div>
<div class="arrow-right move grey"></div>
</div>
<div class="bottom">
<div class="arrow-left light-grey"></div>
<div class="arrow-top same"></div>
<div class="arrow-left lighter" id="align2"></div>
</div>
</div>
<div class="hex">
<div class="back-to-top">Back to Top</div>
</div>
<div class="rhombus"></div>
<div class="contact">
<h1>Contact</h1>
<p class="number">(480)456-7297</p>
<p class="email">fakeEmail#fake.com</p>
<div class="textarea">
<textarea name="" id="" cols="30" rows="0" placeholder="Send us a message:)"></textarea>
<button>Send</button>
<div class="links">
<p>Leave us a review!</p>
<i class="fab fa-facebook-square" id="facebook"></i>
<i class="fab fa-yelp" id="yelp"></i>
<i class="fab fa-twitter-square" id="twitter"></i>
</div>
</div>
</div>
<div class="contact-line"></div>
<div class="location">
<h1>Location</h1>
<div class="map">
<i class="fas fa-map-marker-alt"></i>
6140 E Main St.
<div class="street-1">
<p class="street-info">63rd St.</p>
</div>
<div class="street-2">
<p class="street-info">N Recker Rd.</p>
</div>
<div class="street-3">
<p class="street-info">US 60 E.</p>
</div>
</div>
</div>
<div class="contact-design-wrap-right">
<div class="top">
<div class="arrow-left lighter" id="align"></div>
<div class="arrow-left light-grey"></div>
<div class="arrow-right grey"></div>
<div class="arrow-top same"></div>
</div>
<div class="top-middle">
<div class="arrow-left light-grey"></div>
<div class="arrow-right grey"></div>
</div>
<div class="bottom-middle">
<div class="arrow-right grey"></div>
<div class="arrow-left light-grey"></div>
<div class="arrow-right move grey"></div>
</div>
<div class="bottom">
<div class="arrow-left light-grey"></div>
<div class="arrow-top same"></div>
<div class="arrow-left lighter" id="align2"></div>
</div>
</div>
<p class="copyright">© 2019 El Metate | All Rights Reserved</p>
</div>
</footer>

The easiest solution is to give the textarea display: block so that it honors left/right margins. You can update the css inside your final media query like this:
.contact textarea {
width: 90%;
margin-left: auto;
margin-right: auto;
display: block;
}
But the min-width: 500px on the div surrounding the textarea is also causing some alignment issues. You may want to try adjusting that at smaller screen sizes as well.

Related

Hover event not working with biggest z-index

I have a gallery item with some image in its body. It has to display MORE link in the center of the body when I hover over gallery item (which works just fine) and display 0.5 opacity when I hover over MORE link. Even though z-index is bigger than parent's, for some reason :hover event simply does not fire. Any clue on how to fix this? My cursor: pointer also does not work.
HTML:
<div class="gallery _flex-between">
<div class="gallery__item gallery-item _flex-column-center">
<div class="gallery-item__body">
<div class="gallery-item__more-container">
<a class="gallery-item-more">More →</a>
</div>
<img src="/resources/projects/1.jpg" alt="" class="gallery__img">
</div>
<div class="gallery-item__footer">
Everlasting Summer
</div>
</div>
</div>
CSS:
._absolute-cover {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
.gallery {
margin-top: 4em;
width: 90%;
}
.gallery-item__footer {
font-size: 1.6rem;
margin-top: 1em;
width: 100%;
border: 1px solid black;
text-align: center;
border-radius: 35px;
padding: .5em 0;
letter-spacing: 2px;
background-color: white;
transition: background-color .3s, color .3s;
}
.gallery__item {
position: relative;
width: 30%;
max-width: 600px;
}
.gallery-item__more-container {
display: flex;
align-items: center;
justify-content: center;
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0,0,0,0);
transition: background-color .3s;
border-radius: 35px;
z-index: 2;
}
.gallery-item__link {
position: absolute;
width: 100%;
height: 100%;
cursor: default;
z-index: 4;
}
.gallery-item-more {
position: relative;
z-index: 1000000000;
width: 50%;
background-color: rgba(255, 255, 255, 1);
opacity: 0;
transition: background-color .3s;
color: black;
font-weight: bold;
letter-spacing: 1px;
padding: 1em 0;
border-radius: 35px;
text-align: center;
cursor: pointer;
}
.gallery-item-more:hover {
background-color: rgba(255, 255, 255, .5);
}
.gallery-item__link:hover ~ .gallery-item__footer {
background-color: black;
color: white;
}
.gallery-item__link:hover ~ .gallery-item__body .gallery-item__more-container {
background-color: rgba(0,0,0,0.8);
}
.gallery-item__link:hover ~ .gallery-item__body .gallery-item-more {
opacity: 1;
}
.gallery-item__body {
width: 100%;
position: relative;
}
._flex-column-center {
display: flex;
flex-direction: column;
align-items: center;
}
.gallery__img {
object-position: top;
height: 25vw;
width: 100%;
border-radius: 35px;
}
Move the image before the more-button and it should work: Codepen
<div class="gallery _flex-between">
<div class="gallery__item gallery-item _flex-column-center">
<div class="gallery-item__body">
<img src="/resources/projects/1.jpg" alt="" class="gallery__img">
<div class="gallery-item__more-container">
<a class="gallery-item-more">More →</a>
</div>
</div>
<div class="gallery-item__footer">
Everlasting Summer
</div>
</div>
</div>

Why does <a> tag give a different output from <li> tag when applying a hover background?

Link to my jsfiddle work
I switched my "navbar" from a basic header navigation bar to a custom layout.
I changed my li tags to an a tag to include classes and separate css designs.
Following this change, my link didn't change colors when I hovered over them.
Is there a reason as to why this would occur when I include classes in my tags.
.tl,
.tc,
.tr,
.bl,
.bc,
.br {
text-decoration: none;
color: green;
font-size: 24px;
font-family: Bungee Shade;
cursor: pointer;
border-radius: 10px;
transition: .5s;
position: fixed;
}
.tl {
top: 45px;
left: 60px;
}
.tc {
margin-top: 45px;
text-align: center;
right: 50%;
}
.tr {
margin-top: 45px;
right: 60px;
}
.bl {
bottom: 45px;
margin-left: 60px;
}
.bc {
bottom: 45px;
text-align: center;
right: 50%;
}
.br {
bottom: 45px;
right: 60px;
}
.tl:hover,
.tc:hover,
.tr:hover,
.bl:hover,
.bc:hover,
.br:hover {
background-color: orange;
}
<div class="navbar">
<a class="tl" href="#">HOME</a>
<a class="tc" href="#">MUSIC</a>
<a class="tr" href="#">BIO</a>
<a class="bl" href="#">TOUR</a>
<a class="bc" href="#">SHOP</a>
<a class="br" href="#">TSA</a>
</div>
Please try to add some padding, or some dimensions, on the a tag classes (not on the hover state) and see if it works. a tags work inline so if they have no dimensions, they have no background.
you have to add the position:relative and z-index to your navbar as your slider is currently overlapping it. so hover is not happening on a tag
* {
padding: 0px;
margin: 0px;
box-sizing: border-box;
/*background-image: url(test.JPG);*/
}
.navbar{
position: relative;
z-index: 2;
}
.tl, .tc, .tr, .bl, .bc, .br{
text-decoration: none;
color: green;
font-size: 24px;
font-family: Bungee Shade;
cursor: pointer;
border-radius: 10px;
transition: .5s;
position: fixed;
}
.tl{
top: 45px;
left: 60px;
}
.tc{
margin-top: 45px;
text-align: center;
right: 50%;
}
.tr{
margin-top: 45px;
right: 60px;
}
.bl{
bottom: 45px;
margin-left: 60px;
}
.bc{
bottom: 45px;
text-align: center;
right: 50%;
}
.br{
bottom: 45px;
right: 60px;
}
.tl:hover, .tc:hover, .tr:hover, .bl:hover, .bc:hover, .bl:hover{
background-color: orange;
}
#slider, .wrap, .slide-content{
margin: 0;
padding: 0;
font-family: Bungee Shade ;
width: 100%;
height: 100vh;
overflow-x: hidden;
overflow-y: hidden;
}
.wrap{position:relative;}
.slide{
background-size: cover;
background-position: center;
background-repeat: no-repeat;
}
.slide1{background-image: url('img/goho.jpg');
width: 330px;
height: 330px;
left: 33.3%;
margin-top: 12%;
position: fixed;
}
.slide2{background-image: url('');
}
.slide3{background-image: url('');}
.slide-content{
/*Text in the middle*/
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
text-align: center;
}
.slide-content span{
font-size: 15px; /*rem*/
color: black;
}
.arrow{
cursor: pointer;
position: absolute;
top: 50%;
margin-top: -30px;
width: 0;
height: 0;
border-style: solid;
}
#arrow-left{
border-width: 30px 40px 30px 0;
border-color: transparent #000 transparent transparent;
left: 0;
margin-left: 30px;
}
#arrow-right{
border-width: 30px 0 30px 40px;
border-color: transparent transparent transparent #000;
right: 0;
margin-right: 30px;
}
<div class="navbar">
<a class="tl" href="#">HOME</a>
<a class="tc" href="music.htm">MUSIC</a>
<a class="tr" href="#">BIO</a>
<a class="bl" href="#">TOUR</a>
<a class="bc" href="#">SHOP</a>
<a class="br" href="#">TSA</a>
</div>
<div class ="wrap">
<div id="arrow-left" onclick="slideLeft()" class="arrow"></div>
<div id="slider">
<div class="slide slide1">
<div class="slide-content"></div>
</div>
<div class="slide slide2">
<div class="slide-content"></div>
</div>
<div id="arrow-right" onclick="slideRight()" class="arrow"></div>
</div>

Divs overlapping instead of stacking on top

I am trying to have multiple divs stack on top of each other. Based on the responses of previously asked similar questions, I used a main container with relative positioning and absolute positioning of divs within. I Even tried giving them z-indexes but the Divs are still overlapping.
Please find the html below; Response 2 fully overlaps Response 1 Div.
body {
background-color: #dbdbdb;
}
h1 {
font-size: 20px;
font-style: normal;
color: #000000;
margin-top: 0px;
}
h2 {
font-size: 22px;
font-style: normal;
font-weight: normal;
color: #000000;
margin-top: 0px;
}
h3 {
font-size: 12px;
font-style: normal;
font-weight: normal;
color: #000000;
margin-top: 0px;
}
p {
font-size: 20px;
font-style: normal;
color: #000000;
}
p.dataTitle {
font-size: 16px;
font-style: normal;
font-weight: bold;
color: #000000;
}
.responsePanel {
border-style: solid;
border-width: 1px;
border-color: black;
}
.titleBar {
background-color: #ffffff;
border-width: 0px;
position: absolute;
left: 0px;
top: 0px;
width: 100%;
height: 50px;
}
.titleText {
position: relative;
left: 35px;
top: 0px;
}
.titleValue {
position: absolute;
left: 35px;
top: 24px;
}
.titleDataSource {
position: absolute;
right: 128px;
top: 34px;
}
.mugshotContainer {
background-color: #ffffff;
border-width: 0px;
position: absolute;
left: 0px;
top: 52px;
width: 33%;
height: 420px;
}
.locationData {
position: relative;
left: 5px;
top: 0px;
}
.personNameContainer {
background-color: #ffffff;
border-width: 0px;
position: absolute;
left: 0%;
top: 52px;
width: 100%;
}
.personName {
position: relative;
left: 5px;
top: 0px;
}
.personDescriptionContainer {
background-color: #ffffff;
border-width: 0px;
position: absolute;
left: 66.60%;
top: 52px;
width: 33.3%;
height: 420px;
}
.activityContainer {
background-color: #ffffff;
border-width: 0px;
position: absolute;
left: 66.60%;
top: 52px;
width: 33.3%;
height: 420px;
}
.personDescriptionData {
position: relative;
left: 5px;
top: 0px;
}
.personLocations {
background-color: #ffffff;
border-width: 0px;
position: absolute;
left: 0px;
top: 474px;
width: 100%;
height: 150px;
}
.personLocationsData {
position: relative;
left: 5px;
top: 0px;
}
table#locationsTable {
width: 99%;
}
table#locationsTable tr:nth-child(even) {
background-color: #eee;
}
table#locationsTable tr:nth-child(odd) {
background-color: #fff;
}
table#locationsTable th {
color: white;
background-color: black;
}
table#locationsTable td {
text-align: center;
}
#response1 {
position: relative;
width: 95%;
}
#response2 {
position: relative;
width: 95%;
}
.outer {
position: relative;
}
<div class="outer">
<div class="responsePanel" id="response1">
<div class="titleBar">
<div class="titleText">
<h1>Game 1</h1>
</div>
<div class="titleValue">
<h2>sas</h2>
</div>
<div class="titleDataSource">
<h3>Data Source: </h3>
</div>
</div>
<div class="personNameContainer">
<!---->
<p class="personName">xyz/p>
</div>
</div>
<div class="responsePanel" id="response2">
<div class="titleBar">
<div class="titleText">
<h1>what</h1>
</div>
<div class="titleValue">
<h2>xyz</h2>
</div>
<div class="titleDataSource">
<h3>Data Source: </h3>
</div>
</div>
<div class="personNameContainer">
<!---->
<p class="personName">blah blah</p>
</div>
</div>
</div>
JS Fiddle
https://jsfiddle.net/qe36n9hm/1/

Sideway rotate text with background

Hello I'm trying to make something like this with css Image Link.
I've tried transform: skew(0deg, -35deg); and transform: rotate(-45deg); but the background color isn't as the image.
you can try this
.container{
border: 1px solid black;
margin: 40px;
height: 400px;
position: relative;
overflow: hidden;
}
.rotated{
background: maroon;
color: white;
transform: rotate(45deg);
text-align: center;
width: 100px;
position: absolute;
right: -25px;
top: 15px;
}
<div class="container">
<div class="rotated">TEXT</div>
</div>
You can use this css approach for this
.card {
width:300px;
height: 300px;
position: relative;
background: #ddd;
overflow: hidden;
}
.tag {
position: absolute;
top:5px;
right:-24px;
background: #990000;
padding: 5px 30px;
text-align: center;
transform: rotate(45deg);
-webkit-transform: rotate(45deg);
color: #fff;
font-size: 14px;
}
<div class="card">
<div class="tag">New</div>
</div>
Well, I tested this only in chrome. I hope this can serve as a starting point for you.
https://jsfiddle.net/pablodarde/af5c9x78/
.container {
display: flex;
justify-content: center;
align-items: center;
width: 380px;
height: 380px;
background: linear-gradient(#D4EDFF, #fff);
}
.inner {
width: 300px;
height: 300px;
background: #fff;
box-shadow: 0 0 2px rgba(0,0,0,.1);
}
.holder-tag {
position: relative;
width: 0;
height: 0;
left: 300px;
}
.holder-tag .tag {
position: absolute;
right: -30px;
top: 20px;
border-bottom: 20px solid #900;
border-left: 20px solid transparent;
border-right: 20px solid transparent;
height: 10px;
width: 90px;
transform: rotate(45deg);
}
.holder-tag span {
position: absolute;
right: -18px;
top: 25px;
width: 110px;
line-height: 1px;
color: #fff;
font: normal 14px Arial, Verdana;
text-align: center;
padding: 5px 0 0 0;
box-sizing: border-box;
transform: rotate(45deg);
}
.content {
width: 80%;
padding: 10px;
}
<div class="container">
<div class="inner">
<div class="holder-tag">
<div class="tag"></div>
<span>new</span>
</div>
<div class="content">
<p>
You can write text here without worrying about space.
</p>
</div>
</div>
</div>

How can I make another skew container inside a skewed parent container using css

I am creating a simple layout using skews and my layout is like this:
And what I desired is something like this:
My problem is I can't make another div with skew inside the parent container.
Here's my CSS and HTML:
/*** VCONTENT ***/
#v-container {
position: relative;
background: #000;
}
#homepage-content-banner {
margin-top: 50px;
margin-bottom: 90px;
position: relative;
text-align: center;
z-index: 0;
background: #000;
}
#homepage-content-banner h1 {
font-family: times new roman;
color: #fff;
font-size: 80px;
margin-top: 35%;
}
#homepage-banner-images {
background-image: url('../images/top-banner-full.png');
background-repeat: no-repeat;
position: relative;
padding-left: 0px;
padding-right: 0px;
max-width: 100%;
max-height: 100%;
background-size: 100%;
height: 950px;
min-height: 950px;
margin-bottom: 150px;
}
#scroll-bottom {
color: #fff;
margin-top: 16%;
font-family: blueHighway;
}
#scroll-bottom:hover {
cursor: pointer;
color: #FFF100;
}
#homepage-about-us {
height: 300px;
position: relative;
width: 100%;
padding-left: 0px;
padding-right: 0px;
background: #fff;
}
#homepage-about-us::before {
content: '';
width: 100%;
height: 100%;
position: absolute;
background: inherit;
z-index: 0;
bottom: 0;
transform-origin: left top;
transform: skewY(-10deg);
}
<div id="v-container">
<div class="container-fluid" id="homepage-content-banner">
<div class="row">
<div class="col-md-12" id="homepage-banner-images">
<h1 class="headline">EVERYTHING IN THE WORLD IS<br />UNDER THE SAME SKY</h1>
<div id="scroll-bottom">
<h4>SCROLL</h4>
<div class="fa fa-long-arrow-down fa-2x"></div>
</div>
</div>
</div>
</div>
<div class="container-fluid" id="homepage-about-us">
<div class="inner-line">
<div class="img"></div>
</div>
</div>
</div>
Can you help me with this?
You can create a second item with skewY with ::after:
/*** VCONTENT ***/
#v-container {
position: relative;
background: #000;
}
#homepage-content-banner {
margin-top: 50px;
margin-bottom: 90px;
position: relative;
text-align: center;
z-index: 0;
background: #000;
}
#homepage-content-banner h1 {
font-family: times new roman;
color: #fff;
font-size: 80px;
margin-top: 35%;
}
#homepage-banner-images {
background-image: url('../images/top-banner-full.png');
background-repeat: no-repeat;
position: relative;
padding-left: 0px;
padding-right: 0px;
max-width: 100%;
max-height: 100%;
background-size: 100%;
height: 950px;
min-height: 950px;
margin-bottom: 150px;
}
#scroll-bottom {
color: #fff;
margin-top: 16%;
font-family: blueHighway;
}
#scroll-bottom:hover {
cursor: pointer;
color: #FFF100;
}
#homepage-about-us {
height: 300px;
position: relative;
width: 100%;
padding-left: 0px;
padding-right: 0px;
background: #fff;
}
#homepage-about-us::before {
content: '';
width: 100%;
height: 100%;
position: absolute;
background: inherit;
z-index: 0;
bottom: 0;
transform-origin: left top;
transform: skewY(-10deg);
}
#homepage-about-us::after {
content: '';
width: 100%;
height: 100%;
position: absolute;
background: yellow;
z-index: 0;
bottom: 0;
transform-origin: left top;
transform: skewY(-10deg);
}
<div id="v-container">
<div class="container-fluid" id="homepage-content-banner">
<div class="row">
<div class="col-md-12" id="homepage-banner-images">
<h1 class="headline">EVERYTHING IN THE WORLD IS<br />UNDER THE SAME SKY</h1>
<div id="scroll-bottom">
<h4>SCROLL</h4>
<div class="fa fa-long-arrow-down fa-2x"></div>
</div>
</div>
</div>
</div>
<div class="container-fluid" id="homepage-about-us">
<div class="inner-line">
<div class="img"></div>
</div>
</div>
</div>

Resources