How set the style of the content to default - css

I am using Zurb foundation 3 custom for layout(Grid) and style. Based on the user who is logged in, I need to remove the Zurb styling for some content. But I would like to still keep using the zurb layout.
How can I reset all properties of an element to default value.
Only for the main content of the page I want to set it to default, other part should still use zurb styling.
CSS:
input[type="text"], input[type="password"], input[type="date"], input[type="datetime"], input[type="email"], input[type="number"], input[type="search"], input[type="tel"], input[type="time"], input[type="url"], textarea {
background-color: #eeeeee;
font-family: inherit;
border: 1px solid #cccccc;
-webkit-border-radius: 2px;
-moz-border-radius: 2px;
-ms-border-radius: 2px;
-o-border-radius: 2px;
border-radius: 2px;
-webkit-box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1);
-moz-box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1);
box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1);
color: rgba(0, 0, 0, 0.75);
display: block;
font-size: 14px;
margin: 0 0 12px 0;
padding: 6px;
height: 32px;
width: 100%;
-webkit-transition: all 0.15s linear;
-moz-transition: all 0.15s linear;
-o-transition: all 0.15s linear;
transition: all 0.15s linear;
}
input[type="text"].oversize, input[type="password"].oversize, input[type="date"].oversize, input[type="datetime"].oversize, input[type="email"].oversize, input[type="number"].oversize, input[type="search"].oversize, input[type="tel"].oversize, input[type="time"].oversize, input[type="url"].oversize, textarea.oversize {
font-size: 17px;
padding: 4px 6px;
}
input[type="text"]:focus, input[type="password"]:focus, input[type="date"]:focus, input[type="datetime"]:focus, input[type="email"]:focus, input[type="number"]:focus, input[type="search"]:focus, input[type="tel"]:focus, input[type="time"]:focus, input[type="url"]:focus, textarea:focus {
background: #fafafa;
outline: none !important;
border-color: #b3b3b3;
}
input[type="text"][disabled], input[type="password"][disabled], input[type="date"][disabled], input[type="datetime"][disabled], input[type="email"][disabled], input[type="number"][disabled], input[type="search"][disabled], input[type="tel"][disabled], input[type="time"][disabled], input[type="url"][disabled], textarea[disabled] {
background-color: #ddd;
}
HTML:
<div class="row">
<div class="four columns">
<label for="txtName">* First Name:</label>
</div>
<div class="fourteen columns ">
<input name="ctl00$ContentPlaceHolder1$txtName" type="text" maxlength="25" id="ContentPlaceHolder1_txtName" class="eight" />
</div>
</div>
I have to do this for all controls not just input.
Rendered HTML(View source):

Related

Hint "required" is not shown

What piece of code "deleted" the hint about required field?
https://jsfiddle.net/venntr/qegxnjm2/
<div class="switch-field">
<input type="radio" id="onlinetak" name="online" required/>
<label for="onlinetak">Online</label>
<input type="radio" id="onlinenie" name="online" required />
<label for="onlinenie">Offline</label>
</div>
The first thing to fix is that it is not in a form tag, as was pointed out by Leon.
What's happening is that your CSS is styling your HTML labels, not your radio inputs, to be selected. You set the inputs to be display: none, so the associated errors with there being no input do not display. You need to show the inputs and edit the styling of the inputs themselves so that the error properly appears if there is no input.
EDIT: Here's an example of your code that will work with what I said.
body {
background-color: #F7FCFF;
}
.QA radio {
-webkit-appearance: none;
background-color: #e1e1e1;
border: 4px solid #e1e1e1;
border-radius: 10px;
width: 100%;
display: inline-block;
position: relative;
width: 20px;
height: 20px;
}
.QA radio:checked {
background: grey;
border: 4px solid #e1e1e1;
}
input[type=text], textarea {
-webkit-transition: all 0.30s ease-in-out;
-moz-transition: all 0.30s ease-in-out;
-ms-transition: all 0.30s ease-in-out;
-o-transition: all 0.30s ease-in-out;
outline: none;
padding: 3px 0px 3px 3px;
margin: 5px 1px 3px 0px;
border: 1px solid #DDDDDD;
}
input[type=text]:focus, textarea:focus {
box-shadow: 0 0 5px rgba(81, 203, 238, 1);
padding: 3px 0px 3px 3px;
margin: 5px 1px 3px 0px;
border: 1px solid rgba(81, 203, 238, 1);
}
.QA {
font: normal normal 14px/1 Helvetica;
margin: 1px;
border-radius:10px;
text-align:center;
}
.QA1 {
font: normal normal 14px/1 Helvetica;
border-radius:10px;
text-align:left;
}
.QA h2{
font: normal normal 16px/1 Helvetica;
font-weight: bold;
color:#004E97;
}
.QA button{
text-align:center;
width: auto;
background: #E2F4FE;
font-weight: bold;
font-size: 14px;
text-shadow: none;
color: rgba(0, 0, 0, 0.6);
border: 1px solid rgba(0, 0, 0, 0.2);
border-radius: 5px;
cursor: pointer;
padding: 6px 14px;
margin: 2px;
outline: 0;
-webkit-transition: all 0.3s ease-in-out;
-moz-transition: all 0.3s ease-in-out;
-ms-transition: all 0.3s ease-in-out;
-o-transition: all 0.3s ease-in-out;
transition: all 0.3s ease-in-out;
}
.QA1 button{
text-align:left;
width: auto;
background: #E2F4FE;
font-weight: bold;
font-size: 14px;
text-shadow: none;
color: rgba(0, 0, 0, 0.6);
border: 1px solid rgba(0, 0, 0, 0.2);
border-radius: 5px;
cursor: pointer;
padding: 6px 14px;
margin: 2px;
outline: 0;
-webkit-transition: all 0.3s ease-in-out;
-moz-transition: all 0.3s ease-in-out;
-ms-transition: all 0.3s ease-in-out;
-o-transition: all 0.3s ease-in-out;
transition: all 0.3s ease-in-out;
}
.QA button:hover{
box-shadow: 0 0 0 2px white, 0 0 0 3px #27AE60; background: #C1EEFE;
}
.QA1 button:hover{
box-shadow: 0 0 0 2px white, 0 0 0 3px #27AE60; background: #C1EEFE;
}
textarea {
background-color: #FFFFFF;
}
.index {
z-index: 55;
}
.switch-field {
font-family: Helvetica;
padding: 10px;
overflow: hidden;
font-size:0px;
}
.switch-title {
margin-bottom: 6px;
}
.switch-field .input-field {
text-align:center;
display: inline;
width: auto;
background-color: #F2F0F0;
color: rgba(0, 0, 0, 0.6);
font-size: 14px;
font-weight: bold;
text-shadow: none;
padding: 6px 14px;
border: 1px solid rgba(0, 0, 0, 0.2);
-webkit-box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.3), 0 1px rgba(255, 255, 255, 0.1);
box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.3), 0 1px rgba(255, 255, 255, 0.1);
-webkit-transition: all 0.3s ease-in-out;
-moz-transition: all 0.3s ease-in-out;
-ms-transition: all 0.3s ease-in-out;
-o-transition: all 0.3s ease-in-out;
transition: all 0.3s ease-in-out;
}
.switch-field label:hover {
cursor: pointer;
}
.switch-field input:checked + label {
background-color: #5EA8EE;
-webkit-box-shadow: none;
box-shadow: none;
}
.switch-field .input-field:first-of-type {
border-radius: 4px 0 0 4px;
}
.switch-field .input-field:last-of-type {
border-radius: 0 4px 4px 0;
}
#onlinetak:checked + label:first-of-type { background-color:#5EA8EE; }
#onlinenie:checked + label:last-of-type { background-color:#EE5B5B; }
<form>
<div class="switch-field">
<div class="input-field">
<input type="radio" id="onlinetak" name="online" required/>
<label for="onlinetak">Online</label>
</div>
<div class="input-field">
<input type="radio" id="onlinenie" name="online" required/>
<label for="onlinenie">Offline</label>
</div>
</div>
<button type="submit">Submit</button>
</form>
EDIT 2: Another (admittedly hacky) way of doing it is to set a negative z-index on the inputs themselves so that they don't appear to be inside the labels themselves. The error still shows near the input group, but the inputs are "under" the labels (and not set to display: none), so the error displays where the inputs are.
.switch-field input {
position: absolute;
z-index: -10000;
}
Your code may need to be in a form in order for your required to work.
Code:
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<div class="switch-field">
<form>
<input id="onlinetak" name="online" type="radio"> <label for="onlinetak">Online</label> <input id="onlinenie" name="online" type="radio"> <label for="onlinenie">Offline</label> <button type="submit">Submit</button>
</form>
</div>
</body>
</html>
Jsfiddle - https://jsfiddle.net/qegxnjm2/1/
enter code here
Online
Offline

Jumpy transition when only modifying box-shadow, looks fine with box-shadow + border

The following code snippets show two examples of a text input field. When focused, the bottom of the input increases in thickness and changes color.
The first example uses a combination of border-bottom and box-shadow to achieve the effect. The second example uses just box-shadow. I think that the effects should be identical. However, the box-shadow only example 'jumps' when finishing its transition. Why? Is there a way to improve it?
Example has only been tested on the stable version of Webkit.
input[type="text"] {
border-top: none;
border-left: none;
border-right: none;
padding: 0 0 8px 0;
transition: box-shadow 0.3s, border 0.3s;
will-change: box-shadow, border;
outline: none;
box-sizing: border-box;
}
#example1 {
border-bottom-width: 1px;
border-bottom-color: rgba(0, 0, 0, 0.26);
}
#example1:focus {
border-bottom-color: #2196F3;
box-shadow: inset 0 -1px 0 #2196F3;
}
#example2 {
border-bottom: none;
padding-bottom: 9px;
box-shadow: inset 0 -1px 0 rgba(0, 0, 0, .26);
}
#example2:focus {
box-shadow: inset 0 -2px 0 #2196F3;
}
<input type="text" id="example1" placeholder="I'm a good example">
<input type="text" id="example2" placeholder="I'm a bad example">
Looks fine when I run it, and I'm on Chrome.
The first thing you should do is ensure that you have an up to date browser: transition was only universally adopted a few releases ago.
Secondly, transitions don't work perfectly on every element, or work at all on some.
Use this awesome tool to check the elements you are trying to animate for compatibility:
http://caniuse.com/#feat=css-transitions
input[type="text"] {
border-top: none;
border-left: none;
border-right: none;
padding: 0 0 8px 0;
transition: box-shadow 0.3s, border 0.3s;
will-change: box-shadow, border;
outline: none;
box-sizing: border-box;
}
#example1 {
border-bottom-width: 1px;
border-bottom-color: rgba(0, 0, 0, 0.26);
}
#example1:focus {
border-bottom-color: #2196F3;
box-shadow: inset 0 -1px 0 #2196F3;
}
#example2 {
border-bottom: none;
padding-bottom: 9px;
box-shadow: inset 0 -1px 0 rgba(0, 0, 0, .26);
transition: box-shadow .1s;
}
#example2:focus {
box-shadow: inset 0 -2px 0 #2196F3;
transition: box-shadow .4s;
}
<input type="text" id="example1" placeholder="I'm a good example">
<input type="text" id="example2" placeholder="I'm a bad example">

Top part of box shadow clipped in IE only

On my site I have links with a box shadow that appears when hovering. You can see it on http://www.lorteau.fr . That works just fine on Chrome, Opera and Firefox. IE however clips the top of it.
Chrome, Opera, Firefox:
IE:
HTML defining the links and all the containers around it:
<body>
<div class="main m-scene" id="page">
<div id="menu">
<a class="menu_link" id="wphone_link" href="wphone.html">Windows Phone</a>
<a class="menu_link" id="wmetro_link" href="wmetro.html">Windows Metro</a>
<a class="menu_link" id="wdesktop_link" href="wdesktop.html">Windows Desktop</a>
<a class="menu_link" id="linux_link" href="linux.html">Linux</a>
<a class="menu_link" id="other_link" href="other.html">Other</a>
</div>
</div>
</body>
CSS3 defining the hovering effect and the containers around it:
.html
{
background-color: #464646;
}
body
{
margin: 0;
}
#page
{
width: 900px;
min-width: 800px;
min-height: 100%;
-pie-box-shadow: 0px 0px 3px 1px #FFFFFF;
-moz-box-shadow: 0px 0px 3px 1px rgba(255, 255, 255, 0.5);
-webkit-box-shadow: 0px 0px 3px 1px rgba(255, 255, 255, 0.5);
box-shadow: 0px 0px 3px 1px rgba(255, 255, 255, 0.5);
background-image: none;
border-width: 1px;
border-style: solid;
border-color: #000000;
background-color: #3C3C3C;
margin-left: auto;
margin-right: auto;
margin-top: 0px;
margin-bottom: 0px;
padding: 7px 5px 6px 32px;
}
#menu
{
height: 57px;
display: block;
width: 85%;
margin-left: auto;
margin-right: auto;
margin-top: 5px;
text-align: center;
}
.menu_link, .menu_link:hover
{
font-family: 'Electrolize', Arial, sans-serif;
font-size: 18px;
text-align: left;
color: white;
display: inline;
text-decoration: none;
border-style: solid;
border-width: 1px;
border-color: #777777;
border-radius: 5px;
background-color: #777777;
padding: 5px;
margin-right: 5px;
-webkit-transition: 250ms linear 0s;
-moz-transition: 250ms linear 0s;
-o-transition: 250ms linear 0s;
transition: 250ms linear 0s;
}
.menu_link:hover
{
color: #FFBE5B;
box-shadow: 0px 0px 5px 5px rgba(255, 190, 91, 0.5);
}
.menu_link:active
{
color: #FFBE5B;
}
.m-scene .scene_element
{
animation-duration: 0.25s;
-webkit-animation-duration: 0.25s;
animation-fill-mode: both;
-webkit-animation-fill-mode: both;
transition-timing-function: ease-out;
}
I tried all the padding, margin and height combinations I could think of but that didn't change anything. Would some have an idea as to what I could modify so that the shadow isn't clipped on any browser?
Pff never mind. Removed "margin-top: 5px;" from #menu and added "padding-top: 15px;" and that did it.
Spelling out the question clearly always helps!

CSS element pushes content down

I have 3 elements on my site that starts with an icon, which I have animated with CSS on hover. But when I hover, the whole section is pushed down. I do only wish to affect the icon. This is probably a positioning thing, but I have tried several things that I know of, but nothing seem to work the way I wish. The site is build with Bootstrap by the way, but that is probably not part of my problem.
The site can be seen here: http://www.vielendank.dk/bootstrap
(halfway down - the blue section)
The html look like this:
<div class="span4 text-center">
<div class="komp"><div class="komp-ikon">
<i class="icon-pencil"></i></div>
<h4>Grafisk design</br>og rentegning</h4></br>
Vi elsker design! Grafisk design og rentegning er vielen danks absolutte
spidskompetence – vi vil gå så vidt som at kalde os selv for nørder.
</div></div>
The CSS look like this:
.komp{
display: block;
}
.komp-ikon{
font-size: 40px;
color:#007fa7;
padding-top: 20px;
background-color: white;
width: 80px;
height: 60px;
margin-left: auto;
margin-right: auto;
margin-bottom: 20px;
-moz-border-radius: 6%;-khtml-border-radius: 6%;-webkit-border-radius: 6%;border-radius: 6%;
-moz-box-shadow: 0 1px 10px rgba(0, 0, 0, 0.3);
-webkit-box-shadow: 0 1px 10px rgba(0, 0, 0, 0.3);
box-shadow: 0 1px 10px rgba(0, 0, 0, 0.3);
-moz-transition: all 0.2s ease-in;
-webkit-transition: all 0.2s ease-in;
-o-transition: all 0.2s ease-in;
transition: all 0.2s ease-in;
-ms-transition: all 0.2s ease-in;}
.komp:hover .komp-ikon{
color: #41ab29;
font-size: 60px;
padding-top: 20px;
background-color: white;
width: 100px;
height: 80px;
margin-left: auto;
margin-right: auto;
margin-bottom: 20px;
-moz-border-radius: 4%;-khtml-border-radius: 4%;-webkit-border-radius: 4%;border-radius: 4%;
-moz-box-shadow: 0 1px 10px rgba(0, 0, 0, 0.3);
-webkit-box-shadow: 0 1px 10px rgba(0, 0, 0, 0.3);
box-shadow: 0 1px 10px rgba(0, 0, 0, 0.3);}
.komp:hover h4{
color:#41ab29;
font-family: 'Montserrat Alternates', sans-serif;
font-weight: 400;
margin-bottom: 0px;
padding-bottom: 0px;}
Thanks guys...
Simply give that div a fixed height:
.section.blue {
height: 350px;
}
Or if you want the selector to be more specific:
.section.blue .container .row {
height: 270px;
}
Try this:
CSS
.komp {
display: block;
padding: 100px 0 0;
}
.komp-ikon {
font-size: 40px;
color:#007fa7;
padding-top: 20px;
background-color: white;
width: 80px;
height: 60px;
margin: 0 0 0 -40px;
-moz-border-radius: 6%;
-khtml-border-radius: 6%;
-webkit-border-radius: 6%;
border-radius: 6%;
position: absolute;
top: 20px;
left: 50%;
-moz-box-shadow: 0 1px 10px rgba(0, 0, 0, 0.3);
-webkit-box-shadow: 0 1px 10px rgba(0, 0, 0, 0.3);
box-shadow: 0 1px 10px rgba(0, 0, 0, 0.3);
-moz-transition: all 0.2s ease-in;
-webkit-transition: all 0.2s ease-in;
-o-transition: all 0.2s ease-in;
transition: all 0.2s ease-in;
-ms-transition: all 0.2s ease-in;
}
.komp:hover .komp-ikon {
color: #41ab29;
font-size: 60px;
padding-top: 20px;
background-color: white;
width: 100px;
height: 80px;
margin-left: auto;
margin-right: auto;
margin-bottom: 20px;
-moz-border-radius: 4%;-khtml-border-radius: 4%;-webkit-border-radius: 4%;border-radius: 4%;
-moz-box-shadow: 0 1px 10px rgba(0, 0, 0, 0.3);
-webkit-box-shadow: 0 1px 10px rgba(0, 0, 0, 0.3);
box-shadow: 0 1px 10px rgba(0, 0, 0, 0.3);}
.komp:hover h4{
color:#41ab29;
font-family: 'Montserrat Alternates', sans-serif;
font-weight: 400;
margin-bottom: 0px;
padding-bottom: 0px;
}
HTML
<div class="span4 text-center">
<div class="komp">
<div class="komp-ikon">
<i class="icon-pencil"></i>
</div>
<h4>Grafisk design</br>og rentegning</h4></br>
Vi elsker design! Grafisk design og rentegning er vielen danks absolutte
spidskompetence – vi vil gå så vidt som at kalde os selv for nørder.
</div>
</div>
I positioned it absolutely and then padded the content container so that it wont fall behind the button.
Not sure where you are going to use this, but it might be worth checking into creating a holding container for the button only, to make it more flexible :)
I solved the problem
I addede a
.komp{postition: absolute;}
For some reason you need this to position elements within this element. The only thing now is centering af the icons which does not work with margin-left/right: auto, but I will figure that one out hopefully.
Thanks for the advice...

How to Make a 3D button using CSS?

I have a CSS button that looks like this:
that is formed from this CSS code:
.Button{
color: #333;
border: 1px solid orange;
border-bottom: 5px solid orange;
background-color: #fff;
font-size: 12px;
margin: 5px;
padding: 1px 7px 1px 7px;
display: inline-block;
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
position: relative;
top: 0px;
}
.Button:hover{
cursor: hand;
cursor: pointer;
}
.Button:active{
border-bottom: 3px solid #999;
top: 3px;
}
This is what I am trying to make it look like (but I can't figure out how to do it):
Please pardon my drawing skills. I just want to extend the orange border on the left so it looks 3D. Thanks!
Here is a fiddle for a 3d button I have used in places. It is animated with css to have an active and hover state
fiddle
.btn-big {
background-color: #474EDD;
background-image: -webkit-linear-gradient(283deg, rgba(255, 255, 255, 0.1) 50%, transparent 55%),-webkit-linear-gradient(top, rgba(255, 255, 255, 0.15), transparent);
border-radius: 6px;
box-shadow: 0 0 0 1px #163772 inset,0 0 0 2px rgba(255, 255, 255, 0.15) inset,0 4px 0 0 #333797,0 4px 0 1px rgba(0, 0, 0, 0.4),0 4px 4px 1px rgba(0, 0, 0, 0.5);
color: white !important;
display: block;
font-family: "Lucida Grande", Arial, sans-serif;
font-size: 20px;
font-weight: bold;
height: 61px;
letter-spacing: -1px;
line-height: 61px;
margin: 50px;
position: relative;
text-align: center;
text-shadow: 0 1px 1px rgba(0, 0, 0, 0.5);
text-decoration: none !important;
-webkit-transition: all .2s linear;
width: 186px;
}
.btn-big:active {
background-color: #474EDD;
top: 4px;
box-shadow: 0 0 0 1px #163772 inset,0 0 0 2px rgba(255, 255, 255, 0.15) inset,0 0 0 0 #333797,0 0 0 1px rgba(0, 0, 0, 0.4),0 0px 8px 1px rgba(0, 0, 0, 0.5);
}
.btn-big:hover {
background-color: #5158E0;
poisiton: relative;
top: -1px;
box-shadow: 0 0 0 1px #163772 inset,0 0 0 2px rgba(255, 255, 255, 0.15) inset,0 5px 0 0 #333797,0 5px 0 1px rgba(0, 0, 0, 0.4),0 5px 8px 1px rgba(0, 0, 0, 0.5);
}
I hope that helps!
Would you like to try this way:
http://cssdeck.com/labs/fancy-3d-button
a {
position: relative;
color: rgba(255, 255, 255, 1);
text-decoration: none;
background-color: rgba(219, 87, 5, 1);
font-family: 'Yanone Kaffeesatz';
font-weight: 700;
font-size: 3em;
display: block;
padding: 4px;
-webkit-border-radius: 8px;
-moz-border-radius: 8px;
border-radius: 8px;
-webkit-box-shadow: 0px 9px 0px rgba(219, 31, 5, 1), 0px 9px 25px rgba(0, 0, 0, .7);
-moz-box-shadow: 0px 9px 0px rgba(219, 31, 5, 1), 0px 9px 25px rgba(0, 0, 0, .7);
box-shadow: 0px 9px 0px rgba(219, 31, 5, 1), 0px 9px 25px rgba(0, 0, 0, .7);
margin: 100px auto;
width: 160px;
text-align: center;
-webkit-transition: all .1s ease;
-moz-transition: all .1s ease;
-ms-transition: all .1s ease;
-o-transition: all .1s ease;
transition: all .1s ease;
}
a:active {
-webkit-box-shadow: 0px 3px 0px rgba(219, 31, 5, 1), 0px 3px 6px rgba(0, 0, 0, .9);
-moz-box-shadow: 0px 3px 0px rgba(219, 31, 5, 1), 0px 3px 6px rgba(0, 0, 0, .9);
box-shadow: 0px 3px 0px rgba(219, 31, 5, 1), 0px 3px 6px rgba(0, 0, 0, .9);
position: relative;
top: 6px;
}
<link href='http://fonts.googleapis.com/css?family=Yanone+Kaffeesatz:700' rel='stylesheet' type='text/css'>
Push me!
This is close, but not quite perfect.
Using box-shadow & border:
.Button {
color: #333;
box-shadow: -3px 3px orange, -2px 2px orange, -1px 1px orange;
border: 1px solid orange;
}
http://jsfiddle.net/grYTZ/3/
Try This One you can resize it of course
<html>
<head>
<style>
.button {
background: black;
border-style: outset;
border-width: 4px;
border-color: white;
border-radius: 8px;
color: white;
padding: 8px 15px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
margin: 4px 2px;
cursor: pointer;
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
min-width:500px;
min-height: 100px;
}
.button:hover{
border-style: outset;
border-width: 2px;
box-shadow: none;
background: black;
</style>
</head>
<body>
Link Button
</body>
</html>
You can do this using this example from the perspective page on MDN. You can change the view by setting the perspective-origin in .button-container. My example is also animated so that clicking on the button will show motion. You can change that using the transition function in .side.
JSFiddle
<div class="container">
<div class="button-container">
<div class="bottom side"></div>
<div class="left side"></div>
<div class="right side"></div>
<div class="top side"></div>
<button class="button side" type="button">Click Me</button>
</div>
</div>
.button-container {
--dimension: 100px;
--adjustment: 0px;
--red-accent: #B11807;
--red-dark: #710F05;
--red: #E31D09;
height: 100%;
perspective: 700px;
perspective-origin: 150% 150%;
transform-style: preserve-3d;
width: 100%;
}
.button-container:active {
--adjustment: 100px;
}
.side {
border: none;
box-sizing: border-box;
display: block;
height: calc(var(--dimension) - var(--adjustment));
position: absolute;
transition: 0.4s ease-out;
width: calc(var(--dimension) - var(--adjustment));
}
.bottom {
background: var(--red-accent);
transform: rotateX(-90deg) translateZ(calc(var(--dimension) / 2 + var(--adjustment) / 2));
width: var(--dimension);
}
.button {
background-color: var(--red);
color: #FFFFFF;
height: var(--dimension);
transform: translateZ(calc(var(--dimension) / 2 - var(--adjustment) / 2));
width: var(--dimension);
}
.left {
background: var(--red-dark);
height: var(--dimension);
transform: rotateY(-90deg) translateZ(calc(var(--dimension) / 2 - var(--adjustment) / 2));
}
.right {
background: var(--red-dark);
height: var(--dimension);
transform: rotateY(90deg) translateZ(calc(var(--dimension) / 2 + var(--adjustment) / 2));
}
.top {
background: var(--red-accent);
transform: rotateX(90deg) translateZ(calc(var(--dimension) / 2 - var(--adjustment) / 2));
width: var(--dimension);
}
.container {
box-sizing: border-box;
padding: 100px;
height: 300px;
width: 300px;
}

Resources