Sideway rotate text with background - css

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>

Related

margin auto isn't centering flex item [duplicate]

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.

How to draw simple line in box with html/css

Simple question, but don't know how to google it.
When no quantity to draw line. How to draw in list box something like this?
Just need simple css answer. Thank you.
You can do that by adding a pseudo element to the quantity element.
.quantity {
display: inline-block;
padding: 8px 12px;
border: 1px solid #000;
position: relative;
overflow: hidden;
}
.quantity--strikethrough:before {
content: '';
width: 100%;
height: 2px;
background: blue;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%,-50%) rotate(-45deg);
transform-origin: 50% 50%;
}
<div class="quantity">
6 vnt.
</div>
<div class="quantity quantity--strikethrough">
12 vnt.
</div>
If you simply want to draw a line on the element, this could be of use to you. Hope it helps!
.element{
position:relative;
display: inline-block;
}
.element:before{
content: "";
height: 1px;
width: 100%;
position:absolute;
top:50%;
background-color: #000;
}
<p class="element">Empty</p>
.block {
border: 1px solid;
display: inline-block;
margin: 2px;
padding: 0 2px;
position: relative;
overflow: hidden;
}
.line:before {
position: absolute;
content: "";
left: -10%;
top: 50%;
right: -10%;
border-top: 2px solid blue;
transform: rotate(-35deg);
}
<div class="block">100</div>
<div class="block line">50</div>
<div class="block line">50</div>
<div class="block line">150</div>
here is my try
div {
position: relative;
display: inline-block;
border: 1px solid #333;
padding: 10px;
float: left;
margin: 10px;
}
.cutoff {
overflow: hidden;
}
.cutoff::after {
height: 1px;
content: '';
width: 100%;
position: absolute;
background-color: blue;
left: 0;
transform: rotate(145deg);
top: 20px;
}
<div class="">
some text
</div>
<div class="cutoff">
some text
</div>
<div class="cutoff">
some text
</div>

how to make cornered button with css?

How do I make a button like this with pure CSS?
That's all that I've been capable of:
.sideMenuButton {
width: 100px;
height: 100px;
background: #6d1a3e;
position: relative;
transform: rotate(-90deg);
border: none;
}
.sideMenuButton:after {
content: '';
position: absolute;
bottom: 0;
left: 0;
border-top: 29px solid #6d1a3e;
border-left: 29px solid #fff;
width: 42px;
height: 0;
}
<button type="button" class="sideMenuButton">X</button>
but it's not working right way
Just a quick try. I hope this could help you.
You can add text by the text attribute of the button.
.button-container{
width: 100px;
height: 100px;
overflow: hidden;
position:relative;
margin: 5px;
}
.button {
width: 148px;
height: 200px;
transform: rotateZ(45deg);
overflow: hidden;
position: absolute;
top: -68px;
left: -43px;
}
.button::before{
content: attr(text);
background: #6d1a3e;
display: block;
width: 100px;
height: 100px;
transform: rotateZ(-45deg);
position: absolute;
top: 50px;
left: 50px;
border: 5px solid #a5285e;
cursor: pointer;
box-sizing: border-box;
text-align: center;
vertical-align: middle;
line-height: 69px;
font-size: 2.5em;
color: white;
}
.button::after{
content: '';
display: block;
position: absolute;
border-bottom: 7px solid #a5285e;
border-left: 5px solid transparent;
border-right: 5px solid transparent;
height: 0;
width: 41px;
transform: rotateZ(90deg);
top: 99px;
left: 120px;
cursor: pointer;
}
.other.button::before{
border-left: none;
border-top: none;
line-height: 80px;
font-size: 3em;
}
<div class="button-container">
<div class="button" text="PDF"></div>
</div>
<div class="button-container">
<div class="button other" text="☰"></div>
</div>

CSS bottom triangle background

I want to create same bottom triangle effect with background but i am not able to get this effect bottom triangle with background image.
enter image description here
i have added the code here but not getting the same effect.bottom arrow im not able to extend as in image.
.logo,.nav,.social-icons{ float:left;}
body{ color:#000; background:#ccc;}
.container{border:1px solid red;}
.clear{ clear:both;}
html,body{margin:0;padding:0;}
/*****************************
BANNER
*****************************/
.section {
height: 680px;
width: 100%;
background: url("http://i.imgur.com/YtluDV9l.jpg") no-repeat left top;
background-size:cover;
}
.bottom-container {
margin-top: -137px;
height: 100px;
width: 100%;
}
.text {
position: relative;
box-sizing: border-box;
height: 300px;
padding-top: 36px;
text-align: center;
line-height: 85px;
background: url("http:////i.imgur.com/uCYtKen.jpg") no-repeat left top;
background-clip: content-box;
overflow: hidden;
margin: 25px 0 0 0;
}
.text:before {
left: 0px;
width: 26%;
transform-origin: left bottom;
transform: skew(-134deg);
}
.text:after, .text:before {
position: absolute;
content: '';
top: 0px;
height: 35px;
background: #fff;
}
.text:after {
right: 2px;
width: 74%;
transform-origin: right bottom;
transform: skew(-226deg);
}
<body>
<!--WRAPPER:STARTS-->
<div id="wrapper">
<!--HEADER:STARTS-->
<!--BANNER:STARTS-->
<section class="section">
</section>
<div class="bottom-container">
<div class="text">Some text</div>
<div class="middle-image"></div>
<div class="right-image"></div>
</div></div>
</body>
html,body{background:url(http://i.imgur.com/ixr4wNC.jpg); height:100%;padding:0;margin:0;overflow:hidden;}
.line {
margin-top: 50px;
height: 5px;
width: 20%;
background: #fff;
position: relative;
box-sizing: border-box;
}
.line:after,
.line:before {
content: "";
position: absolute;
}
.line:after {
left: calc(100% + 2px);
height: 25px;
width: 25px;
top: -12px;
border-top: 5px solid #fff;
border-left: 5px solid #fff;
transform: rotate(225deg);
}
.line:before {
height: 100%;
top: 0;
left: calc(100% + 34px);
width: 400px;
background: inherit;
}
<div class="line"></div>
Is this the same that you are looking for?
Here is JSFiddle
Hope this helps.

How to position a text inside a rotated div box

Like this
Should be centered too.
.diamond {
display: block;
height: 30px;
width: 30px;
background-color: white;
border: 2px solid #dcdcdc;
transform: rotate(45deg);}
Rotate the content back the other way.
* {
margin: 0;
padding: 0;
}
.diamond {
display: block;
height: 30px;
width: 30px;
background-color: white;
border: 2px solid #dcdcdc;
transform: rotate(45deg);
text-align: center;
line-height: 30px;
margin: 25px;
}
.diamond p {
transform: rotate(-45deg);
}
<div class="diamond">
<p>Hi</p>
</div>
I would use a pseudo element for this.
Then i only need to apply one rotation.
That rotation is only on a single element.
.mid-angle {
color: black;
width: 50px;
height: 50px;
text-align: center;
line-height: 50px;
}
.mid-angle:before {
content: " ";
display: block;
position: absolute;
width: 50px;
height: 50px;
box-sizing: border-box;
border: 2px solid pink;
transform: rotate(45deg);
}
<div class="mid-angle">Hello</div>

Resources