hide form with css3 and show default div.
Tags: html5,css3
Problem :
I only can use html5 and css3. I have a form and I need simulate "send form data". After click in submit button I need to hide the form and show some default div (#result). How can I do this (only css3 and html5, no javascript).
Thanks.
This is my HTML + CSS code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>CSS CHALLENGE</title>
<style>
@import url(http://fonts.googleapis.com/css?family=Raleway:400 "Raleway");
@import url(http://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css);
.global {
background-color: #353535;
font: 14px/21px "Lucida Sans", "Lucida Grande", "Lucida Sans Unicode", sans-serif;
}
.backgound {
background-color: whitesmoke;
height: 530px;
width: 400px;
margin:0 auto 0 auto;
-moz-border-radius: 7px;
-webkit-border-radius: 7px;
}
#loginForm {
-moz-border-radius: 7px;
-webkit-border-radius: 7px;
font-family: Raleway;
font-size: 20px;
font-style: normal;
font-variant: small-caps;
font-weight: 200;
line-height: 26.4px;
}
.header {
margin-left: 40px;
}
#triangle {
width: 0;
height: 0;
border-left: 12px solid transparent;
border-right: 12px solid transparent;
border-top: 12px solid cornflowerblue;
margin-top: 29px;
left: 54px;
position: relative;
}
#loginForm h2 {
background: cornflowerblue;
color: white;
height: 55px;
font-size: 2.5em;
padding-top: 10%;
-moz-border-radius: 7px;
-webkit-border-radius: 7px;
font-family: Raleway;
font-size: 39px;
font-style: normal;
font-variant: small-caps;
font-weight: 200;
line-height: 26.4px;
}
.item {
display: -webkit-box;
height: 30px;
width: 300px;
margin: 0 auto 15px;
background-color: white;
-moz-border-radius: 4px;
-webkit-border-radius: 4px;
}
#idMessage {
height: 160px;
}
#loginForm button{
opacity: 0.5;
transition:opacity .3s;
-webkit-transition:opacity .3s;
background-color: darkolivegreen;
width: 308px;
height: 60px;
-moz-border-radius: 7px;
-webkit-border-radius: 7px;
font-size: 2em;
}
#loginForm:valid button {
opacity: 1;
}
#result {
display: none;
}
#result:target {
display:block;
}
.myLoad {
position: relative;
}
.myLoad i {
position: absolute;
top: 8px;
left: 325px;
}
#val {
display: none;
}
.#idEmail:invalid #val {
display: block;
}
input:invalid .val {
display: block;
}
#idEmail:invalid, #idMessage:invalid{
color: red;
}
#idEmail:valid, #idMessage:valid{
color: green;
}
/* fa-spin*/
</style>
</head>
<body class="global">
<div class="backgound">
<form id="loginForm" action="#result" method="get">
<h2>
<span class="header">Contact Us!</span>
<div id="triangle"></div>
</h2>
<div class="myLoad">
<input class="item" id="idEmail" type="email"
placeholder="Email" required>
<i id="inval" class="fa fa-refresh"></i>
<i id="val" class="fa fa-refresh fa-spin"></i>
</input>
</div>
<div class="myLoad">
<input class="item" id="idSubject" type="text"
placeholder="Subject">
<i class="fa fa-refresh"></i>
</div>
<div class="myLoad">
<textarea class="item" id="idMessage" placeholder="Message"
rows="10" cols="40" required></textarea>
<i class="fa fa-refresh"></i>
</div>
<button class="item" type="submit">Send</button>
</form>
<div id="result" class="sended">Form sended</div>
</div>
</body>
</html>
Solution :
I think you're on the right track using the :target
pseudo-class. However, you need to switch the order of the result div and the form, and then combine it with a general sibling selector, see my example here.
(Using the button to submit the form doesnt quite seem to work, but I think that's because the iframing, hopefully it should work for you. Try clicking the test link on jsfiddle to navigate to #result.)
CSS Howto..
give the bar a position of fixed, and set its bottom to 0px, then set your menu to have a bottom of the height of your bar, in this case...
Things that I changed: Changed the link to display as a block element. Removed the padding at the top of the li elements. Added that padding height to the height...
There are a number of issues here. I've modified the layout to be more inline with the way most developers set up this type of menu. I've also reversed most...
Your selectors, once corrected: #some_element, #some_element :first-child { ... } Is the shortest way it can be written in CSS; unfortunately CSS has – as yet – has no shortcut...
Why is width:100% not an option? You can use media queries to target different screen sizes like so: form { width: 800px; } @media only screen and (max-width: 800px) {...
Without a code sample it's hard to tell where you are. If you managed to get the button to hide the blocks (like you said with ng-click="showBlocks={'display': 'block'}) then adding...
The browser support for multiple backgrounds is pretty good nowadays, if you wanted 2 full size background images on top of each other you could declare them both in the...
As you said, you don't want the content of the table to be wrapped so you can use something like this: #container table * { white-space: nowrap; } And I...
this tutorial help you. http://css-tricks.com/scrollfollow-sidebar/ or this one html <div id="header">HEADER</div> <div id="content"> <div id="left">LEFT</div> <div id="right">RIGHT</div> </div> <div id="footer">FOOTER</div> js $(function() { var $sidebar =...
The first script in that article replaces the stylesheet in all <link> elements. You'll want to specify which <link> to change (as in the second example in that article which...
The height parameter of froala accepts valid CSS values like 100px, 100, or 100%. As a result, you can use browser detection to fairly effectively decide which value to set....
Link: jsFiddle. Also add to previous collumn border-right and you will get that you want. I think that collumn's right border is over next collumn left border. JavaScript: $('td').hover(function() {...
The borders are not counted within the div's box. They are to add, and thus are messing up your set, its width is : 3boxes * (33%+3px+3px), which is likely...
The problem seems to be with how FF interprets table cells. If you change the overflow value to 'auto' or 'scroll' it displays as if it were 'overflow:visible' which won't...
You can either change border: 1px solid #DDD; to border: 0; @ style.css line 935 But that will affect all images in that style. If you don't want that you...
As litelite said; Your first issue lies in the invalid style attributes. Those will likely cause problems on some browsers. Now, my personal opinion is that you should avoid using...
Pretty vague, but here's your solution: use the dev tools in your browser of choice, but i'm going to explain using Chrome: hover over the affected jqgrid table and click...
For Links If you actually mean the background on the links themselves, then apply a css class name to each link and style them individually. For example: <ul> <li class="homeLink"><a...
Since you look for a table like layout, stay with your inline block and give them a width (and a minor markup change, where I swapped the progress/text tags) Note,...
How's this: https://jsfiddle.net/sp3rLang/4/ var justify = document.getElementById('v-justify'); var maxHeight = justify.parentElement.clientHeight; var fontSize = 1; while ( maxHeight > justify.clientHeight ) { justify.style.fontSize = fontSize++ + 'px'; } // the...
First, you need to ensure you're passing those $args to the wp_nav_menu() function as such "wp_nav_menu($args)". Second, you have just about everything you need and might not realize it. =)...
Here is a fiddle: https://jsfiddle.net/u3urw5wy/ Add in background-image:url(AddImageUrlHere) to replace background-color: #fff; as below: #progressbar > div { -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box;...
To only way to override inline style is by using !important keyword beside the CSS rule. Following is an example of it. div { color: blue !important; /* Adding !important...
Concerning the Carousel not working If you are using JQuery, you could try calling this after loading the Carousel: $(window).resize() Without jquery you could call this window.dispatchEvent(new Event('resize')); This won't...
Add text-align:center; to .nav ul in your Tinkerbin example. or: #navContainer ul { text-align:center; } to your own css...
I used moredemons's answer as a basis, using CSS triangles. It does the same thing, but it properly separates the CSS so you don't have to edit the JS to...
You would media queries to do this. https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Media_queries img { width: 500px; } @media ( max-width 1200px ) { img { width: 41.66%; } .img2 { width: 42%; } }...
One possible way is something like this (.hMenu is the outer ul here): .hMenu > li { /* for direct childs (>) of .hMenu that are li-s */ /* inline-block...
This is a sample which I have tried. try this. <head> <title>Search</title> <style> #searchcontrol { margin-LEFT:500PX; } </style> <script src="https://www.google.com/jsapi" type="text/javascript"></script> <script language="Javascript" type="text/javascript"> //<!...
This is the jquery I have used $('#a').hover(function(){ $('#a').css('background','#ccc'); $('#b').css('background','#ccc'); }, function(){ $('#a').css('background','#fff'); // Background of #a by default $('#b').css('background','#fff'); // Background of #b by default }) $('#b').hover(function(){...