How create this effect 3D with CSS3 - css

The effect I'm trying to make is as in this image:
http://i271.photobucket.com/albums/jj146/cosmossx/footer.jpg
I've made some progress as you can see in this FIDDLE
css:
.final{ background:#000;
width:100%;}
.triangle {
border-color: white black black black;
border-style: solid;
border-width: 15px 25px 25px 25px;
height: 0px;
width: 500px;
margin: 0 auto;
}
.triangle2 {
border-color: black white white white;
border-style: solid;
border-width: 15px 25px 25px 25px;
height: 0px;
width: 500px;
margin: 0 auto;
}
HTML:
<div class="final"> <div class="triangle"></div>
<br>
<br>
<br>
<br>
<br><br>
<br>
<br>
</div>
<div class="triangle2"></div>
My question is: what would be the best way to make it?
Thanks.

Best approach would be using css transform function and pseudo-elements
DEMO
Source (using Sass and Autoprefixer for brevity):
<footer class="footer">
<div class="footer__main">
<div class="footer__inner">
<div class="footer__content">
<!-- content goes here -->
</div>
</div>
</div>
<div class="footer__bottom"></div>
</footer>
.footer {
height: 500px;
}
.footer__main {
height: 80%;
background: #eee;
}
.footer__bottom {
height: 20%;
background: darken(#eee, 20);
}
.footer__inner {
background: white;
max-width: 800px;
margin: 0 auto;
height: 100%;
padding: 0 20px;
position: relative;
}
.footer__content {
background: #eee;
height: 100%;
transform: translateY(20px);
position: relative;
&:before,
&:after {
content: "";
background: darken(#eee, 10);
width: 20px;
height: 100%;
position: absolute;
top: 0; bottom: 0;
z-index: 2;
}
&:before {
right: 100%;
transform-origin: 100%;
transform: skewY(45deg);
}
&:after {
transform-origin: 0;
left: 100%;
transform: skewY(-45deg);
}
}

Related

Problem using CSS to make an arch-like curve on a design layout

Am working on a design of a card whereby I need to make the red/maroon part bend inwards (from the black part) using css. Please assist?
HTML Markup
<div class="container phonecard2">
</div>
<div class="btm-right">
</div>
CSS code
.container.phonecard2 {
position: relative;
background: #000;
margin-top: 140px;
width: 35%;
height: 260px;
padding: 20px;
-moz-border-radius:15px;
-webkit-border-radius:15px;
border-radius: 15px;
}
.btm-right{
position: absolute;
width: 0;
height: 0;
bottom: 0;
right:0;
border-style: solid;
border-width: 0 0 160px 450px;
border-color: transparent transparent #ba0c2f transparent;
}
PNG image of my design after the above code
<div class="container phonecard2">
<div class="btm-right"></div>
</div>
<style>
.container.phonecard2 {
position: relative;
background: linear-gradient(to left, #ba0c2f 70%, #000000 30%);
margin-top: 140px;
width: 600px;
height: 260px;
padding: 20px;
border-radius: 15px;
overflow: hidden
}
.btm-right {
position: absolute;
background: #000;
width: 800px;
height: 680px;
left: -130px;
top: -330px;
border-radius: 0 0 580px 0;
transform: rotate(21deg);
}
</style>

"Transparent" border around items on background

There have been several questions regarding some kind of transparent border but not what I am looking for, I think.
It might be very stupid but: Is it possible somehow to have items (those white squares) on a background (the black texture) with those items each having a border that "remove" the background for a 10px (or whatever) border?
So you have a continuous background and each item on top of it "cuts out" some part of it.
A true "transparent" border (like other questions) obviously would just let you see the background, so that is not what I mean.
If not, what would be the way to achieve a responsive design like that?
Sorry, I don't know any other way to explain it. Thank you.
See example/fiddle here: jsfiddle.net/14nn2pLy
html, body {
margin: 0;
padding: 0;
height: 100%;
background: #fd1dfa;
}
#main_header {
position: fixed;
top: 0px;
width: 100%;
height: 200px;
background: url() no-repeat center top;
background-size: contain;
}
#main_footer {
position: fixed;
bottom: 0px;
width: 100%;
height: 200px;
background: url(https://preview.ibb.co/hACMzS/background_footer.png) no-repeat center bottom;
background-size: contain;
}
#icons {
position: fixed;
bottom: 0px;
width: 900px;
height: 75px;
background: url(https://preview.ibb.co/mkPODn/footer_items.png) no-repeat center bottom;
border: 10px;
border-color: rgba( 0, 0, 0, 0);
}
<div id="main_header"></div>
<div id="main_footer">
<div id="icons"></div>
</div>
My thought process
The only way I can think of is to make the border the same color as the background (in your case, that shade of pink), but note that this is only possible if there is a solid background color.
Example:
.bg {
position: relative;
height: 250px;
width: 500px;
background-image: url(https://i.imgur.com/nRXO8xa.jpg);
}
.border {
height: 20px;
position: absolute;
top: 0;
bottom: 0;
left: 30px;
margin: auto;
padding: 10px;
background: steelblue;
border: 10px solid black;
}
.no-border {
height: 20px;
position: absolute;
top: 0;
bottom: 0;
right: 30px;
margin: auto;
padding: 10px;
background: steelblue;
border: 10px solid #F7F2D5;
}
<div class="bg">
<div class="border">black border</div>
<div class="no-border">"transparent" border</div>
</div>
Solution:
The desired effect is possible using clip-path on the background. Notice that I've changed the HTML and CSS too, otherwise it wouldn't work. The clip-path is used to basically cut out the part of the background image you don't want, so that it becomes transparent, and it is activated on hover.
body,
html {
height: 100%;
margin: 0;
}
body {
background: url(https://images.unsplash.com/photo-1473662712020-75289ee3c5de);
background-size: cover;
}
.container {
height: 140px;
width: 618px;
position: relative;
top: 40%;
margin: 0 auto;
}
.bg {
height: 140px;
width: 618px;
position: relative;
}
.icon {
height: 50px;
width: 50px;
position: absolute;
top: 25.25%;
left: 38.25%;
z-index: 1;
}
.icon:hover+.bg {
clip-path: polygon(0 0, 0 100%, 44% 78.5%, 37.5% 50%, 44% 22%, 50.5% 50%, 44% 78.5%, 0 100%, 100% 100%, 100% 0);
}
<div class="container">
<div class="icon">
<img src="https://i.imgur.com/V2eI4Rm.png" alt="icon">
</div>
<div class="bg">
<img src="https://i.imgur.com/D3V3ZYq.png" alt="background">
</div>
</div>
you could create a image with transparent background and use that as a border-image.
.background {
position: relative;
width: 100%;
height: 100%;
padding: 10px;
background-color: #fd1dfa;
z-index: 1 !important;
}
.background:after {
content: "";
display: table;
clear: both;
}
hr {
border: 10px solid white;
position: relative;
top: 100px;
z-index: 5 !important;
}
.center {
position: relative;
width: 50px;
height: 50px;
background-color: #fd1dfa;
color: #ffffff;
padding: 10px;
z-index: 10 !important;
}
.border {
position: relative;
z-index: 8 !important;
margin: 30px;
width: 70px;
height: 70px;
float: left;
background: white;
border: 10px solid transparent;
border-image:
}
<div class="background">
<hr>
<div class="border">
<div class="center">
text and words
</div>
</div>
<div class="border">
<div class="center">
text and words
</div>
</div>
<div class="border">
<div class="center">
text and words
</div>
</div>
</div>

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>

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 create circle with four quarters [duplicate]

This question already has answers here:
CSS: Circle with four colors and only one div
(3 answers)
Closed 7 years ago.
Is it possible to create a circle using only CSS with four quarters in it?
I can't get further than:
.circle {
border-radius: 50%;
width: 40px;
height: 40px;
colour: red;
}
<div class="circle"> </div>
Easily...using borders and a rotation.
.circle {
margin: 1em auto;
border-radius: 50%;
width: 40px;
height: 40px;
box-sizing: border-box;
border-width: 20px;
border-style: solid;
border-color: red green blue yellow;
transform: rotate(45deg);
}
<div class="circle"></div>
You can even have colored hollow circles.
.circle {
border-radius: 50%;
width: 40px;
height: 40px;
box-sizing: border-box;
border-width: 20px;
border-style: solid;
border-color: red green blue yellow;
transform: rotate(45deg);
}
.wide {
width: 100px;
height: 100px;
}
<div class="circle wide"></div>
Or perhaps with pseudo-elements (no rotation needed), just gradients.
*,
*::before,
*::after {
box-sizing: border-box;
}
.circle {
width: 100px;
height: 100px;
margin: 1em auto;
position: relative;
border-radius: 50%;
overflow: hidden;
border: 6px solid pink; /* borders on it too */
}
.circle::before,
.circle::after {
content: '';
position: absolute;
height: 100%;
width: 50%;
top: 0;
}
.circle::before {
left: 0;
background: linear-gradient(green, green 50%, yellow 50%);
}
.circle::after {
left: 50%;
background: linear-gradient(red, red 50%, blue 50%);
}
<div class="circle"></div>
Sure (https://jsfiddle.net/to42ug5y/), you're stuck with just 4 quarters however:
<div id="circle">
<div id="q1" class="quarter"></div>
<div id="q2" class="quarter"></div>
<div id="q3" class="quarter"></div>
<div id="q4" class="quarter"></div>
</div>
CSS:
#circle {
display: block;
padding: 0;
width: 200px;
height: 200px;
border: 1px;
border-radius: 50%;
overflow: hidden;
}
.quarter {
display: inline-block;
float: left;
margin: 0;
padding: 0;
width: 100px;
height: 100px;
}
#q1 {
background-color: #f00;
}
#q2 {
background-color: #0f0;
}
#q3 {
background-color: #00f;
}
#q4 {
background-color: #0ff;
}
This will do it for you https://jsfiddle.net/DIRTY_SMITH/bpxr7858/
HTML
<div id="container">
<div id="part1-wrapper" class="cover">
<div id="part1" class="pie"></div>
</div>
<div id="part2-wrapper" class="cover">
<div id="part2" class="pie"></div>
</div>
<div id="part3-wrapper" class="cover">
<div id="part3" class="pie"></div>
</div>
<div id="part4-wrapper" class="cover">
<div id="part4" class="pie"></div>
</div>
</div>
CSS
#container {
position: relative;
width: 100px;
height: 100px;
}
.cover {
position: absolute;
width: 100%;
height: 100%;
clip: rect(0 100px 100px 50px);
}
.pie {
position: absolute;
width: 100%;
height: 100%;
border-radius: 50%;
clip: rect(0 50px 100px 0px);
}
#part1-wrapper {
transform: rotate(0deg);
}
#part1 {
background-color: red;
transform: rotate(90deg);
}
#part2-wrapper {
transform: rotate(90deg);
}
#part2 {
background-color: green;
transform: rotate(90deg);
}
#part3-wrapper {
transform: rotate(180deg);
}
#part3 {
background-color: yellow;
transform: rotate(90deg);
}
#part4-wrapper {
transform: rotate(270deg);
}
#part4 {
background-color: blue;
transform: rotate(90deg);
}

Resources