Make a custom shape in CSS for menu icon - css

I have an svg icon for a website that I would like to make into a css shape so that I can make a custom effect on hover.
I am using pure CSS for this and am not sure I am approaching the problem correctly.
.wrapper {
position: relative;
height: 100vh;
}
.square {
height: 40px;
width: 40px;
background-color: black;
transition: all .2s;
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
}
.square:before {
content: "";
width: 100%;
height: 2px;
background-color: #fff;
display: inline-block;
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
}
.square:after {
content: "";
width: 100%;
height: 2px;
background-color: #fff;
display: inline-block;
position: absolute;
left: 50%;
top: 50%;
transform-origin: 50%;
transform: translate(-50%, -50%) rotate(90deg);
}
.square:hover {
transform: scale(1.2) translate(-50%, -50%);
}
.square:hover .square:before {
transform: scale(1.2);
}
.square:hover .square:before, .square:hover .square:after {
height: 4px;
}
<div class="wrapper">
<div class="square"></div>
</div>
https://codepen.io/Portismouth/pen/ZEEXeVP
so far I am using a simple square with a cross created using the :before and :after psuedo-selectors. On hover, Im trying to make the square bigger and the lines thicker to give the impression i'm going for.
It's basically a 2 x 2 grid of squares that I want to expand out from the middle of the square on hover. Should I create a square with four separate squares or continue with my approach so far.
Thanks in advance.

Your code works correctly. If you want to hover and it'll expand from middle of square, don't use translate(-50%, -50%); when hover on square
.wrapper {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
.square {
height: 40px;
width: 40px;
background-color: black;
transition: all .2s;
}
.square:before {
content: "";
width: 100%;
height: 2px;
background-color: #fff;
display: inline-block;
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
}
.square:after {
content: "";
width: 100%;
height: 2px;
background-color: #fff;
display: inline-block;
position: absolute;
left: 50%;
top: 50%;
transform-origin: 50%;
transform: translate(-50%, -50%) rotate(90deg);
}
.square:hover {
transform: scale(2);
}
<div class="wrapper">
<div class="square"></div>
</div>

Related

Absolutely positioned responsive circle

I am trying to build a responsive, rotating circle similar to the one in this screenshot http://grab.by/PRrw from the www.wove.com menu.
So far, I have a responsive circle using a percentage padding-top and width to make the circle fit a minimum 100vh div, and elements placed on that circle. The issue is ensuring that the elements on the circle remain in place when the browser is resized. Any ideas on the best approach to accomplish this?
jsFiddle: https://jsfiddle.net/szjkrbut/1/
The CSS
.radial-menu {
border: solid 1px #999;
border-radius: 50%;
height: auto;
padding-top: 105%;
position: absolute;
right: -50%;
top: 50%;
-webkit-transform: translateY(-50%);
-moz-transform: translateY(-50%);
transform: translateY(-50%);
width: 105%;
z-index: 1;
}
.radial-item {
display: block;
left: 50%;
margin: 0;
position: absolute;
top: 50%;
width: 35%;
max-width: 290px;
&:after {
background: #999;
border-radius: 50%;
content: '';
height: 8px;
position: absolute;
right: -40px;
top: 50px;
transition: 300ms all ease;
width: 8px;
}
&.item-1 {
transform: rotate(22deg) translate(-231%, 35px);
}
&.item-2 {
transform: rotate(0deg) translate(-237%, 35px);
}
&.item-3 {
transform: rotate(-22deg) translate(-240%, 35px);
}
}

Position :after below the div

I am trying to apply the solution found in the this question, but it is not working in my case.
I want to bring the red circle above the green line.
.box{
border: 1px solid blue;
height: 100px;
position: relative;
width: 100px;
}
.dot{
background: red;
border-radius: 50%;
height: 30px;
width: 30px;
position: absolute;
right: -15px;
top: 50%;
-webkit-transform: translateY(-50%);
transform: translateY(-50%);
}
.dot:after{
background: green;
content: '';
height: 100px;
width: 10px;
position: absolute;
top: 50%;
left: 50%;
-webkit-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
z-index: -1;
}
<div class="box">
<div class="dot"></div>
</div>
<div class="box">
<div class="dot"></div>
</div>
Can't you just make the red dot be an :after rather than the element styles itself?
.box{
border: 1px solid blue;
height: 100px;
position: relative;
width: 100px;
}
.dot {
position: absolute;
top: 0;
right: 0;
width: 0;
height: 100%;
z-index: 1;
}
.dot:after{
background: red;
content: '';
border-radius: 50%;
height: 30px;
width: 30px;
position: absolute;
right: -15px;
top: 50%;
-webkit-transform: translateY(-50%);
transform: translateY(-50%);
}
.dot:before{
background: green;
content: '';
height: 100px;
width: 10px;
position: absolute;
top: 50%;
left: 50%;
-webkit-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
}
<div class="box">
<div class="dot"></div>
</div>
<div class="box">
<div class="dot"></div>
</div>

:before / :after tag in inline css (workaround?)

So I'm trying to put animated css into an email signature. I got it to work in iOS / Mac email-clients, but Gmail and Outlook seem to block part of the code. Does anyone maybe know of a workaround?
The code that I use now in my email:
<!doctype HTML>
<html style="margin: 0; padding: 0;">
<head style="margin: 0; padding: 0;">
<style rel="stylesheet" style="margin: 0; padding: 0;" type="text/css">
* { margin: 0; padding: 0; }
.container {
background: #64B1EE;
width: 100%;
height: 100%;
position: absolute;
overflow: hidden;
}
.airplane {
position: absolute;
left: 40%;
top: 10%;
z-index: 3;
-webkit-animation: plainfly 10s linear infinite;
-o-animation: plainfly 10s linear infinite;
animation: plainfly 10s linear infinite;
}
.airplane div {
background: #F9FBFC;
border-radius: 100%;
width: 60px;
height: 60px;
position: absolute;
z-index: 1;
}
div.head {
top: 21px;
left: 83px;
width: 60px;
height: 25px;
border-radius: 100%;
}
div.body {
top: 20px;
left: 0;
width: 130px;
height: 26px;
border-radius: 40% 30% 20% 50%;
z-index: 1
}
div.lwing {
top: 7px;
left: 60px;
height: 21px;
width: 30px;
border-radius: 5px;
z-index: 0 ;
-webkit-transform: skew(51deg, 0deg);
-ms-transform: skew(51deg, 0deg);
-o-transform: skew(51deg, 0deg);
transform: skew(51deg, 0deg);
}
div.rwing {
top: 34px;
left: 57px;
height: 27px;
width: 35px;
border-radius: 5px;
z-index: 1;
box-shadow: 0px 6px 4px rgba(0, 0, 0, 0.16);
-webkit-transform: skew(-49deg, 0deg);
-ms-transform: skew(-49deg, 0deg);
-o-transform: skew(-49deg, 0deg);
transform: skew(-49deg, 0deg);
}
div.tale {
top: 15px;
left: 10px;
width: 16px;
height: 16px;
border-radius: 2px;
-webkit-transform: skew(35deg, -9deg);
-ms-transform: skew(35deg, -9deg);
-o-transform: skew(35deg, -9deg);
transform: skew(35deg, -9deg);
background: linear-gradient(0deg,#FFF, #BBDEFF);
}
div.window,
div.window:before,
div.window:after {
content: "";
top: 6px;
left: 48px;
width: 4px;
height: 4px;
border-radius: 30%;
background: #9AD0F5;
border: 1px solid #5093D1;
position: absolute;
}
div.window:before {
left: -12px;
top: -1px;
}
div.window:after {
left: 10px;
top: -1px;
}
div.window:nth-child(1){
left:81px
}
div.window:nth-child(2){
left:115px
}
div.window:nth-child(2):after {
border-top-right-radius: 8px;
width: 6px;
}
#-webkit-keyframes plainfly {
0% {
left: -10%;
-webkit-transform: scale(.4);
-ms-transform: scale(.4);
-o-transform: scale(.4);
transform: scale(.4);
}
50% {
left: 110%;
-webkit-transform: scale(1);
-ms-transform: scale(1);
-o-transform: scale(1);
transform: scale(1);
}
51% {
-webkit-transform: rotateY(180deg);
-webkit-transform: rotateY(180deg);
-ms-transform: rotateY(180deg);
-o-transform: rotateY(180deg);
transform: rotateY(180deg);
}
100% {
left: -10%;
-webkit-transform: scale(1.4) rotateY(180deg);
-ms-transform: scale(1.4) rotateY(180deg);
-o-transform: scale(1.4) rotateY(180deg);
transform: scale(1.4) rotateY(180deg);
}
}
#-webkit-keyframes cloud {
0% { left: 15%; }
50% { left: 63%; }
100% { left: 15%; }
}
#-webkit-keyframes cloud_a {
0% { left: 62%; }
50% { left: 90%; }
100% { left: 62%; }
}
#-webkit-keyframes cloud_b {
0% { left: 50%; }
50% { left: 23%; }
100% { left: 50%; }
}
#-webkit-keyframes cloud_c {
0% { left: 37%; }
50% { left: 47%; }
100% { left: 37%; }
}
#-webkit-keyframes cloud_d {
0% { left: 25%; }
50% { left: 65%; }
100% { left: 25%; }
}
</style>
</head>
<body style="margin: 0; padding: 0;">
<div class="container" style="background: #64B1EE; height: 100%; margin: 0; overflow: hidden; padding: 0; position: absolute; width: 100%;"><airplane class="airplane" style="animation: plainfly 10s linear infinite; left: 40%; margin: 0; padding: 0; position: absolute; top: 10%; z-index: 3;"><div class="head" style="background: #F9FBFC; border-radius: 100%; height: 25px; left: 83px; margin: 0; padding: 0; position: absolute; top: 21px; width: 60px; z-index: 1;">
</div>
<div class="body" style="background: #F9FBFC; border-radius: 40% 30% 20% 50%; height: 26px; left: 0; margin: 0; padding: 0; position: absolute; top: 20px; width: 130px; z-index: 1;">
<div class="window" style="background: #9AD0F5; border: 1px solid #5093D1; border-radius: 30%; content: ""; height: 4px; left: 48px; margin: 0; padding: 0; position: absolute; top: 6px; width: 4px; z-index: 1;">
</div>
<div class="window" style="background: #9AD0F5; border: 1px solid #5093D1; border-radius: 30%; content: ""; height: 4px; left: 48px; margin: 0; padding: 0; position: absolute; top: 6px; width: 4px; z-index: 1;">
</div>
<div class="window" style="background: #9AD0F5; border: 1px solid #5093D1; border-radius: 30%; content: ""; height: 4px; left: 48px; margin: 0; padding: 0; position: absolute; top: 6px; width: 4px; z-index: 1;">
</div>
</div>
<div class="lwing" style="background: #F9FBFC; border-radius: 5px; height: 21px; left: 60px; margin: 0; padding: 0; position: absolute; top: 7px; transform: skew(51deg, 0deg); width: 30px; z-index: 0;">
</div>
<div class="rwing" style="background: #F9FBFC; border-radius: 5px; box-shadow: 0px 6px 4px rgba(0, 0, 0, 0.16); height: 27px; left: 57px; margin: 0; padding: 0; position: absolute; top: 34px; transform: skew(-49deg, 0deg); width: 35px; z-index: 1;">
</div>
<div class="tale" style="background: linear-gradient(0deg,#FFF, #BBDEFF); border-radius: 2px; height: 16px; left: 10px; margin: 0; padding: 0; position: absolute; top: 15px; transform: skew(35deg, -9deg); width: 16px; z-index: 1;">
</div></airplane></div>
</body>
</html>
Jsfiddle to make it easier: https://jsfiddle.net/rvrvbtL9/
Any help would be greatly appreciated! Thanks in advance.
The problem you are having is created by the email clients removing everything within a <style> tag. Email clients all process HTML emails different and most of the time you will have to use limited inline styles with a table based layout for best compatiblity.
This is a great resource.
MattSizzle has already written everything I was planning to say about CSS in emails and email clients (along with the same reference link).
In your case, using an animated GIF instead of a CSS animation might be a good practice. It has better browser compatibility as seen here. Nevertheless, animated GIF in email has its own drawbacks, such as "some Outlook versions not showing the animation but the first frame only". Take a look at the article. It may help.
The issue is that Gmail will allow styles but they must NOT be in the body, the previous poster is correct that they require inline css and nothing global. They also strip the HEAD. They strip out class, id and styles from the body. Also no positioning may NOT be used even if its inline. Images need to be on a publicly accessible server, Outlook for instance will not handle base64 encoded images.
Your solution: Remove your classes, all positioning code, HEAD, and convert everything inline. You can use this tool to help you do that: MailChimp Inline converter Instead of positioning, tables are your friend.
Litmus is a fantastic tool to view your html in several clients.

Recreate this radial image using css

I would like to know if it's possible to recreate the following image using css.
I am currently using it but in svg format.
Imagine this:
jsfiddle link
#circle {
background: #ccc;
border-radius: 50%;
/* Change these two equally to change circle size. Can be pixels, too. */
width: 25%;
padding-top: 25%;
height: 0;
position: relative;
}
.hand {
background: black;
width: 1px;
height: 100%;
position: absolute;
left: 50%;
top: 0;
}
.hand:nth-child(2) {
transform: rotate(90deg);
}
.hand:nth-child(3) {
transform: rotate(45deg);
}
.hand:nth-child(4) {
transform: rotate(135deg);
}
#circle:after {
content: '';
display: block;
width: 80%;
height: 80%;
border-radius: 50%;
background: white;
position: absolute;
top: 10%;
left: 10%;
}
<div id="circle">
<div class="hand"></div>
<div class="hand"></div>
<div class="hand"></div>
<div class="hand"></div>
</div>
Or if you need the middle to be transparent (this is a little hacky, and you may have to modify it to fit your exact needs): https://jsfiddle.net/wdoe8r3m/1/

Image in center position in determined height

I'm trying to position an image in determined height.
Just like this main image:
http://littlelines.com/
I have this:
HTML
<div class="present100">
<img id="imagem" src="teste.jpg" />
</div>
CSS
.present100 {
width: 100%;
height: 620px;
background-color: #333;
position: absolute;
overflow: hidden;
top: 0;
left: 0;
margin: auto;
}
#imagem {
position: relative;
width: 100%;
min-width: 1300px;
min-height: 100%;
}
I don't know how to center the image on resize just like the http://littlelines.com/
Not sure why you have absolute position on the .present100 element, but you will have to absolutely position the image as well
#imagem {
position: absolute;
width: 100%;
min-width: 1300px;
min-height: 100%;
left:50%;
top:50%;
-ms-transform: translate(-50%, -50%);
-moz-transform: translate(-50%, -50%);
-webkit-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
}
Demo at http://jsfiddle.net/gaby/vMyvc/

Resources