Inline & Block Form Inputs together - css

I'm trying to give my form a layout like the one shown on this image http://reversl.net/demo/ where the firstname and surname inputs are inline but all other inputs are stacked (i.e. on top of each other). I currently have something like this http://reversl.net/form/ using the following markup;
<div class="container">
<form>
<ol>
<li>
<label for=name>Firstname:</label>
<input id=name name=name type=text placeholder="Jon" required autofocus>
</li>
<li>
<label for=name>Surname:</label>
<input id=surname name=surname type=text placeholder="Doe" required autofocus>
</li>
<li>
<label for=message>Message:</label>
<textarea id=message name=message placeholder="Type your message here..." required></textarea>
</li>
</ol>
</form>
</div>
Styled as follows;
label {
display: block;
line-height: 1.75em;
}
input, textarea {
width: 250px;
display: inline-block;
margin-bottom: 2em;
padding: .75em .5em;
color: #999;
border: 1px solid #e9e9e9;
outline: none;
}
input:focus, textarea:focus {
-moz-box-shadow: inset 0 0 3px #aaa;
-webkit-box-shadow: inset 0 0 3px #aaa;
box-shadow: inset 0 0 3px #aaa;
}
textarea {
height: 100px;
}

Give the first two LIs display: inline-block and adjust paddings/margins as necessary.

I make it
HTML
<div class="container">
<form>
<ul style="float: left">
<label for="name">Firstname</label>
<input id="name" autofocus="" name="name" placeholder="Jon" required="" type="text">
</ul>
<ul style="float: left">
<label for="name">Surname</label>
<input id="surname" autofocus="" name="surname" placeholder="Doe" required="" type="text">
</ul>
<br><br><br><br><br>
<ul>
<ul style="padding: 0px; margin: 0px">
Message</ul>
<textarea id="message" name="message" placeholder="Type your message here..." required="" style="width: 536px"></textarea>
</ul>
</form>
</div>
and CSS
label {
display: block;
line-height: 1.75em;
}
input, textarea {
width: 250px;
display: inline-block;
margin-bottom: 2em;
padding: .75em .5em;
color: #999;
border: 1px solid #e9e9e9;
outline: none;
}
input:focus, textarea:focus {
-moz-box-shadow: inset 0 0 3px #aaa;
-webkit-box-shadow: inset 0 0 3px #aaa;
box-shadow: inset 0 0 3px #aaa;
}
textarea {
height: 100px;
}
ul {
margin: 0px;
}

Related

How to put a textarea and text inut over each other next to a radio?

I have to make a website homework and I have a problem with positioning a text input and a text area above each other next to a bigger radio box.
I've seen a similar post on stack overflow but my problem wasn't solved with that.I'd need something like this: https://i.stack.imgur.com/MUApR.png
.szavazas {
margin-left: 5%;
margin-top: 3%;
}
.raddio {
float: left;
width: 200px;
margin-bottom: 5%;
color: white;
background: green;
border-radius: 8px;
border: 1px solid #003300;
text-align: left;
box-shadow: 0 0 2px 1px black;
height: 350px;
}
input[type="radio"] {
text-align: left;
margin-top: 10px;
margin-bottom: 10px;
}
.velemeny {
float: left;
box-shadow: 0 0 2px 1px black;
width: 200px;
height: 175px;
}
.textin {
float: left;
border: 1px solid black;
background-color: #003300;
color: white;
width: 200px;
height: 165px;
}
<div class="szavazas">
<form class="raddio" action="/action_page.php">
<input type="radio" name="noveny" value="Nagy Flamingóvirág">Nagy Flamingóvirág<br>
<input type="radio" name="noveny" value="Gerbera">Gerbera<br>
<input type="radio" name="noveny" value="Szobai Futóka">Szobai Futóka<br>
<input type="radio" name="noveny" value="Rákvirág">Rákvirág<br>
<input type="radio" name="noveny" value="Zöldike">Zöldike<br>
<input type="radio" name="noveny" value="Borostyán">Borostyán<br>
<input type="radio" name="noveny" value="Azálea">Azálea<br>
<input type="radio" name="noveny" value="Anyósnyelv">Anyósnyelv<br>
<input type="radio" name="noveny" value="Tarka Sárkányfa">Tarka Sárkányfa<br>
<input type="radio" name="noveny" value="Filodendron">Filodendron<br>
</form>
<textarea class="velemeny" rows="7" cols="40" placeholder="Irja le a véleményét a növényről/virágról és hogy találkozott-e már vele? "></textarea>
<form class="textin" action="/action_page.php">
Itt lesz valami hosszu szoveg amit ide fogok irni <br>
<input type="text" name="masiknoveny">
</form>
</div>
You can use flexproperty to align them the way you want. It is a very strong css property and can be used to create any layout you need.
the code below should help you to understand and get started with it.
More about flex : https://codepen.io/enxaneta/full/adLPwv/
.layout {
display: flex;
}
.right-side {
display: flex;
flex-direction: column;
}
.szavazas {
margin-left: 5%;
margin-top: 3%;
}
.raddio {
float: left;
width: 200px;
margin-bottom: 5%;
color: white;
background: green;
border-radius: 8px;
border: 1px solid #003300;
text-align: left;
box-shadow: 0 0 2px 1px black;
height: 350px;
}
input[type="radio"] {
text-align: left;
margin-top: 10px;
margin-bottom: 10px;
}
.velemeny {
float: left;
box-shadow: 0 0 2px 1px black;
width: 200px;
height: 175px;
}
.textin {
float: left;
border: 1px solid black;
background-color: #003300;
color: white;
width: 200px;
height: 165px;
}
<div class="layout">
<div class="left-side">
<form class="raddio" action="/action_page.php">
<input type="radio" name="noveny" value="Nagy Flamingóvirág">Nagy Flamingóvirág<br>
<input type="radio" name="noveny" value="Gerbera">Gerbera<br>
<input type="radio" name="noveny" value="Szobai Futóka">Szobai Futóka<br>
<input type="radio" name="noveny" value="Rákvirág">Rákvirág<br>
<input type="radio" name="noveny" value="Zöldike">Zöldike<br>
<input type="radio" name="noveny" value="Borostyán">Borostyán<br>
<input type="radio" name="noveny" value="Azálea">Azálea<br>
<input type="radio" name="noveny" value="Anyósnyelv">Anyósnyelv<br>
<input type="radio" name="noveny" value="Tarka Sárkányfa">Tarka Sárkányfa<br>
<input type="radio" name="noveny" value="Filodendron">Filodendron<br>
</form>
</div>
<div class="right-side">
<textarea class="velemeny" rows="7" cols="40" placeholder="Irja le a véleményét a növényről/virágról és hogy találkozott-e már vele? "></textarea>
<form class="textin" action="/action_page.php">
Itt lesz valami hosszu szoveg amit ide fogok irni <br>
<input type="text" name="masiknoveny">
</form>
</div>
</div>
I have made some change to your code and achieved the bellow result. Hope this is what you want.
.raddio, .right-side {
float: left;
width: 300px;
margin-bottom: 5%;
color: white;
background: green;
border-radius: 8px;
border: 1px solid #003300;
text-align: left;
box-shadow: 0 0 2px 1px black;
height: 350px;
}
.right-side{
width: 205px;
margin-left: 15px;
border-width:0;
background: transparent;
box-shadow: none;
}
input[type="radio"] {
text-align: left;
margin-top: 10px;
margin-bottom: 10px;
}
.velemeny {
/* float: left; */
box-shadow: 0 0 2px 1px black;
width: 200px;
height: 175px;
border-radius: 8px;
box-sizing: border-box;
margin-bottom: 15px;
}
.textin {
/* float: left; */
border: 1px solid black;
background-color: #003300;
color: white;
width: 200px;
height: 160px;
border-radius: 8px;
padding: 10px;
box-sizing: border-box;
box-shadow: 0 0 2px 1px black;
}
<div class="layout">
<form class="" action="/action_page.php">
<div class="left-side raddio">
<input type="radio" name="noveny" value="Nagy Flamingóvirág">Nagy Flamingóvirág<br>
<input type="radio" name="noveny" value="Gerbera">Gerbera<br>
<input type="radio" name="noveny" value="Szobai Futóka">Szobai Futóka<br>
<input type="radio" name="noveny" value="Rákvirág">Rákvirág<br>
<input type="radio" name="noveny" value="Zöldike">Zöldike<br>
<input type="radio" name="noveny" value="Borostyán">Borostyán<br>
<input type="radio" name="noveny" value="Azálea">Azálea<br>
<input type="radio" name="noveny" value="Anyósnyelv">Anyósnyelv<br>
<input type="radio" name="noveny" value="Tarka Sárkányfa">Tarka Sárkányfa<br>
<input type="radio" name="noveny" value="Filodendron">Filodendron<br>
</div>
<div class="right-side">
<textarea class="velemeny" rows="7" cols="40" placeholder="Irja le a véleményét a növényről/virágról és hogy találkozott-e már vele? "></textarea>
<div class="textin">
Itt lesz valami hosszu szoveg amit ide fogok irni <br>
<input type="text" name="masiknoveny">
</div>
</div>
</form>
</div>

pseudo class preceded by an element

I'm trying to customize the radio and checkboxes using only css. I'm almost there except 2 little details:
here is a markup sample:
<section>
<label class="cbox radio">
<input name="how" type="radio" checked="checked" /> My first radio box
</label>
<label class="cbox radio">
<input name="how" type="radio" /> My second radio box
</label>
<label class="cbox radio">
<input name="how" type="radio" /> My third radio box
</label>
</section>
<section>
<label class="cbox box">
<input name="check1" type="checkbox" checked="checked" /> My first box
</label>
<label class="cbox box">
<input name="check2" type="checkbox" /> My second box
</label>
</section>
Every thing works fine but i can't make it work when the box is checked. I'm trying to use this pseudo class:
*::before, *::after {
box-sizing: border-box;
}
.cbox {
display: block;
position: relative;
margin: 10px 0;
padding-left: 35px;
cursor: pointer;
}
.cbox > input {
position: absolute;
left: -9999px;
}
.cbox::before, .cbox::after {
content: '';
position: absolute;
top: 0;
left: 0;
}
.cbox.radio::before, .cbox.radio::after {
border-radius: 50%;
}
.cbox::before {
display: block;
width: 20px;
height: 20px;
border: 1px solid #c1caca;
}
.cbox::after {
display: none;
width: 12px;
height: 12px;
margin: 4px;
background-color: #2e4a5d;
box-shadow: inset 0 15px 23px -10px rgba(187,230,240,.3),0 2px 2px rgba(0,0,0,.1);
}
/*input:checked + .cbox::before, input:hover + .cbox::before, */
.cbox.on::before, .cbox:hover::before {
background-color: #eaf1f6;
border-color: #a0afbb;
}
/* input:checked + .cbox::after, */
.cbox.on::after {
display: block;
}
And here the jquery
$(".cbox input").change(function() {
if($(this).is(':checked')) $(this).parent('label').toggleClass('on');
});
1- is there a way to make this css work?
2- since the selector :checked is only supported on IE9+, is it recommended to use selectivizr ? or is there a better fallback solution?
Thanks a lot
Just ditch the ::after pseudo class:
.cbox.radio input:checked { display: none; }
<label class="cbox radio">
<input name="how" type="radio" checked="checked" /> My first box
<input name="how2" type="radio" /> My first box
</label>
Fiddle: https://jsfiddle.net/84x66oux/
Btw, you won't be able to customize radios/checkboxes without hiding them in the first place, and adding the whole style yourself. Check this codepen for example
You can try this one
<style>
/*****************************************
RADIO BUTTONS
******************************************/
input[type="radio"] {
display: none;
}
input[type="radio"] + span {
background-color: #fefefe;
border: 1px solid;
border-color: #ccc #fff #fff #ccc;
border-radius: 50px;
box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.15);
display: inline-block;
float: left;
margin-right: 7px;
padding: 7px;
position: relative;
-webkit-appearance: none;
}
input[type="radio"]:checked + span {
color: #f00;
}
input[type="radio"]:checked + span:after {
background: #f00;
border-radius: 50px;
box-shadow: inset 1px 1px 1px rgba(255, 255, 255, 0.75), inset -1px -1px 1px rgba(0, 0, 0, 0.75);
content: " ";
height: 10px;
left: 2px;
position: absolute;
top: 2px;
width: 10px;
}
label:hover input[type="radio"] + span {
border-color: #900 #f00 #f00 #900;
}
</style>
<label>
<input type="radio" name="radio" value="1" checked> <span></span> Option first
</label>
$(".radio input").click(function() {
if ($(this).is(':checked')) {
$(".radio ").removeClass('on')
$(this).parent('label').addClass('on');
}
});
$(".box input").click(function() {
if ($(this).is(':checked')) {
$(this).parent('label').addClass('on');
} else {
$(this).parent('label').removeClass('on');
}
});
*::before,
*::after {
box-sizing: border-box;
}
.cbox {
display: block;
position: relative;
margin: 10px 0;
padding-left: 35px;
cursor: pointer;
}
.cbox > input {
position: absolute;
left: -9999px;
}
.cbox::before,
.cbox::after {
content: '';
position: absolute;
top: 0;
left: 0;
}
.cbox.radio::before,
.cbox.radio::after {
border-radius: 50%;
}
.cbox::before {
display: block;
width: 20px;
height: 20px;
border: 1px solid #c1caca;
}
.cbox::after {
display: none;
width: 12px;
height: 12px;
margin: 4px;
background-color: #2e4a5d;
box-shadow: inset 0 15px 23px -10px rgba(187, 230, 240, .3), 0 2px 2px rgba(0, 0, 0, .1);
}
/*input:checked + .cbox::before, input:hover + .cbox::before, */
.cbox.on::before,
.cbox:hover::before {
background-color: #eaf1f6;
border-color: #a0afbb;
}
/* input:checked + .cbox::after, */
.cbox.on::after {
display: block;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<section>
<label class="cbox radio">
<input name="how" type="radio" /> My first radio box
</label>
<label class="cbox radio">
<input name="how" type="radio" /> My second radio box
</label>
<label class="cbox radio">
<input name="how" type="radio" /> My third radio box
</label>
</section>
<section>
<label class="cbox box">
<input name="check1" type="checkbox" /> My first box
</label>
<label class="cbox box">
<input name="check2" type="checkbox" /> My second box
</label>
</section>

CSS/HTML fieldset with legend side by side

I just wanna ask how can i make that side by side? i know this has already been questioned many times here but i already tried the solutions that they've said worked. like adding <div> or putting a class wrap in the <div> or using box-sizing but neither of them worked.
Any suggestions?
EDITED:
here are my codes:
CSS:
html, body, h1, form, legend, ol, li {
margin: 0;
padding: 0;
}
body {
background: dimgray;
color: #dimgray;
font-family: "Gill Sans MT", sans-serif;
padding: 15px;
}
/*size of the gray box inside legend*/
form#payment {
background: #696969;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
border-radius: 5px;
width: 400px;
}
/*title in the legend/legend itself*/
form#payment legend {
color: #ffffff;
font-size: 16px;
}
/*legend inside the Card details (choosing of card type)*/
form#payment fieldset fieldset legend {
color: #111111;
font-size: 13px;
font-weight: normal;
padding-bottom: 0;
}
/*gray box inside legend*/
form#payment ol li {
background: rgba(255,255,255,.3);
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
border-radius: 5px;
line-height: 30px;
list-style: none;
padding: 5px 10px;
margin-bottom: 2px;
}
form#payment ol ol li {
background: none;
border: none;
float: left;
}
/*input details/label*/
form#payment label {
float: left;
font-size: 13px;
width: 110px;
}
/*arrangement/organization of card type legend*/
form#payment fieldset fieldset label {
background:none no-repeat left 50%;
line-height: 20px;
padding: 0 0 0 30px;
width: auto;
}
form#payment input:not([type=radio]),
form#payment textarea {
background: #ffffff;
border: none;
-moz-border-radius: 3px;
-webkit-border-radius: 3px;
-khtml-border-radius: 3px;
border-radius: 3px;
font: "Gill Sans MT", sans-serif;
outline: none;
padding: 5px;
width: 200px;
}
/*radio button position*/
form#payment input[type=radio] {
float: left;
margin-right: 5px;
}
form#payment button {
background: #191970;
border: none;
-moz-border-radius: 20px;
-webkit-border-radius: 20px;
-khtml-border-radius: 20px;
border-radius: 20px;
color: #ffffff;
font: 18px "Gill Sans MT", sans-serif;
letter-spacing: 1px;
padding: 7px 25px;
text-transform: uppercase;
}
HTML:
<form id="payment">
<fieldset>
<legend>Delivery address</legend>
<ol>
<li>
<label>Address</label>
<textarea name="address" rows="5" required></textarea>
</li>
<li>
<label>Post code</label>
<input name="postcode" type="text" required>
</li>
<li>
<label>Country</label>
<input name="country" type="text" required>
</li>
</ol>
</fieldset>
<fieldset>
<legend>Card details</legend>
<ol>
<li>
<fieldset>
<legend>Card type</legend>
<ol>
<li>
<input name="cardtype" type="radio">
<label for="visa">VISA</label>
</li>
<li>
<input name="cardtype" type="radio">
<label for="mastercard">Mastercard</label>
</li>
</ol>
</fieldset>
</li>
<li>
<label>Card number</label>
<input name="cardnumber" type="number" required>
</li>
<li>
<label>Security code</label>
<input name="secure" type="number" required>
</li>
<li>
<label>Name on card</label>
<input name="namecard" type="text" placeholder="Exact name as on the card" required>
</li>
</ol>
</fieldset>
<br>
<button type="submit">Buy it!</button>
</form>
So if I understand your question right, you want the 2 block elements (Delivery address & Card details) to be next each other?
If that is the case, I would recommend using a framework like Bootstrap or Foundation for this.
Then if you include for example Bootstrap Grid, you can use:
<div class="row">
<div class="col-xs-6">
first block goes here
</div>
<div class="col-xs-6">
second block goes here
</div>
</div>
If this is not what you want, please as already was mentioned, post you code in
JsFiddle

Middle the label for text area input in css3

html
div class="main">
<div class="one">
<div class="register">
<h3>Create your account</h3>
<form id="reg-form">
<div>
<div>
<label for="username">Username</label>
<input type="text" id="username" spellcheck="false" placeholder="User Name" />
</div>
<div>
<label for="password">Password</label>
<input type="password" id="password" />
</div>
<div>
<label></label>
<input type="submit" value="Shop Login" id="create-account" class="button"/>
</div>
</form>
</div>
</div></div>
<div class="two">
<div class="register">
<h3>Create your account</h3>
<form id="reg-form1">
<div>
<label for="name1">Name</label>
<input type="text" id="name1" spellcheck="false" placeholder="Enter Your Name"/>
</div>
<div>
<label for="email1">Email</label>
<input type="text" id="email1" spellcheck="false" placeholder="mymail#mail.com"/>
</div>
<div>
<label for="username1">Username</label>
<input type="text" id="username1" spellcheck="false" placeholder="User Name" />
</div>
<div class="textarea">
<label for="address">Shipping Address</label>
<textarea name="address"cols="35" rows="4"></textarea>
</div>
<div>
<label for="password1">Password</label>
<input type="password" id="password1" />
</div>
<div>
<label for="password-again1">Password Again</label>
<input type="password" id="password-again1" />
</div>
<div>
<label></label>
<input type="submit" value="Create Account" id="create-account1" class="button"/>
</div>
</form>
</div>
</div>
</div>
CSS
.main > div {
display: inline-block;
width: 49%;
margin-top: 20px;
}
.two .register {
border: none;
}
.two .register h3 {
border-bottom-color: #909090;
}
.two .register .sep {
border-color: #909090;
}
.register {
width: 400px;
margin: 10px auto;
padding: 10px;
border: 7px solid #ADD8E6;
border-radius: 10px;
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
color: #444;
background-color: #f0f0f0;
box-shadow: 0 0 20px 0 #000000;
}
.register h3 {
margin: 0 15px 20px;
border-bottom: 2px solid #72b372;
padding: 5px 10px 5px 0;
font-size: 1.1em;
}
.register div {
margin: 0 0 15px 0;
border: none;
}
.register label {
display: inline-block;
width: 25%;
text-align: right;
margin: 10px;
}
.register input[type=text], .register input[type=password] {
width: 65%;
font-family: "Lucida Grande","Lucida Sans Unicode",Tahoma,Sans-Serif;
padding: 5px;
font-size: 0.9em;
border-radius: 5px;
background: rgba(0, 0, 0, 0.07);
}
.register input[type=text]:focus, .register input[type=password]:focus {
background: #FFFFFF;
}
.register textarea{
width: 65%;
font-family: "Lucida Grande","Lucida Sans Unicode",Tahoma,Sans-Serif;
padding: 5px;
font-size: 0.9em;
border-radius: 5px;
background: rgba(0, 0, 0, 0.07);
}
.register .button {
font-size: 1em;
border-radius: 8px;
padding: 10px;
border: 1px solid #ADD8E6;
box-shadow: 0 1px 0 0 #05B8CC inset;
background: #05B8CC;
background: -webkit-linear-gradient(#ADD8E6, #05B8CC);
background: -moz-linear-gradient(#ADD8E6, #05B8CC);
background: -o-linear-gradient(#ADD8E6, #05B8CC);
background: linear-gradient(#ADD8E6, #05B8CC);
}
.register .button:hover {
background: #51db1c;
background: -webkit-linear-gradient(#51db1c, #6ba061);
background: -moz-linear-gradient(#51db1c, #6ba061);
background: -o-linear-gradient(#51db1c, #6ba061);
background: linear-gradient(#51db1c, #6ba061);
}
.register .sep {
border: 1px solid #72b372;
position: relative;
margin: 35px 20px;
}
.register .or {
position: absolute;
width: 50px;
left: 50%;
background: #f0f0f0;
text-align: center;
margin: -10px 0 0 -25px;
line-height: 20px;
}
.register .connect {
width: 400px;
margin: 0 auto;
text-align: center;
}
div.one {position: relative; top: -165px}
The css is working fine, except that the label for text area is displaying at bottom.
How can I display the text area label at center position of the text area ?? Thanks in advance.
Here is a link to Fiddle Demo
Add the following css rule:
div.textarea > * {
vertical-align:middle
}
Add following css in your code
.register label, .register textarea{
vertical-align:middle
}

Fix gap from border-bottom none

I have a <a> tag with border: 1px solid #CCC; border-bottom:none; style and it's leaves a tiny gap, please look at the codepen result to see what I mean. This gap appears left from login tab if the login tab is active or right from register tab if register tab is active.
HTML:
<div id="w-login">
<div id="login">
<menu id="tabs"> <a id="tab-signin" class="tab-active"><i class="fa fa-unlock-alt"></i>Login</a><a id="tab-signup"><i class="fa fa-lock"></i>Register</a>
</menu>
<div id="signin">
<form class="form-horizontal">
<div class="form-group">
<label for="username" class="control-label col-1">Username:</label>
<input type="text" name="username" class="form-control col-2" id="si-username">
</div>
<div class="form-group">
<label for="password" class="control-label col-1">Password:</label>
<input type="password" name="password" class="form-control col-2" id="si-password">
</div>
<input type="submit" value="Login" class="btn btn-primary" id="si-submit">
</form>
</div>
<div id="signup">
<form class="form-horizontal">
<div class="form-group">
<label for="username" class="control-label col-1">Username:</label>
<input type="text" name="username" class="form-control col-2" id="su-username">
</div>
<div class="form-group">
<label for="password" class="control-label col-1">Password:</label>
<input type="password" name="password" class="form-control col-2" id="su-password">
</div>
<div class="form-group">
<label for="email" class="control-label col-1">Email:</label>
<input type="text" name="email" class="form-control col-2" id="su-email">
</div>
<input type="submit" value="Register" class="btn btn-primary" id="su-submit">
</form>
</div>
</div>
</div>
CSS:
#container {
height: 100%;
width: 100%;
text-align: center;
font-size: 14px;
}
#container:before {
content:'';
display: inline-block;
height: 100%;
vertical-align: middle;
margin-right: -3px;
}
#w-login {
display: inline-block;
vertical-align: middle;
width: 40%;
padding: 5px;
}
#login {
}
#signin, #signup {
border: 1px solid #CCC;
border-top: none;
padding: 20px 10px;
border-bottom-left-radius: 15px;
-webkit-border-bottom-left-radius: 15px;
-moz-border-bottom-left-radius: 15px;
border-bottom-right-radius: 15px;
-webkit-border-bottom-right-radius: 15px;
-moz-border-bottom-right-radius: 15px;
}
#signup {
display: none;
}
#tabs {
padding: 0;
margin: 0;
border: 1px solid #CCC;
border-top-left-radius: 15px;
-webkit-border-top-left-radius: 15px;
-moz-border-top-left-radius: 15px;
border-top-right-radius: 15px;
-webkit-border-top-right-radius: 15px;
-moz-border-top-right-radius: 15px;
border-bottom: none;
}
#tabs a {
padding: 10px 0;
display: inline-block;
width: 50%;
cursor: pointer;
text-decoration: none;
}
#tabs .tab-active {
}
#tab-signin.tab-active {
border: 1px solid #CCC;
border-width: 0 1px 1px 0;
}
#tab-signup.tab-active {
border: 1px solid #CCC;
border-width: 0 0 1px 1px;
}
.col-1 {
width: 28%;
}
.col-2 {
width: 70%;
display: inline-block;
}
.form-horizontal .form-group {
margin-right: 0;
margin-left: 0;
}
.btn {
width: 99%;
}
.fa {
padding-right: 5px;
}
Note: the rest of the CSS styles come from Bootstrap
JS/jQuery:
$(function(){
$('#tab-signin').click(function(){
$('#signup').hide();
$('#signin').show();
switchTab();
});
$('#tab-signup').click(function(){
$('#signin').hide();
$('#signup').show();
switchTab();
});
});
function switchTab(){
$('#tabs a').toggleClass('tab-active');
}
I suggest the following approach.
I would take advantage of the fact that in your mark-up the two tab elements,
#tab-signin and #tab-signup, are children of the menu#tabs element.
That being the case, I would place the left, top and right borders on the #tabs element
and remove the left/top and top/right borders on the two children elements (#tab-signin and #tab-signup respectively).
The CSS for #tabs would look like:
#tabs{
padding: 0;
margin: 0;
border: 1px solid #CCC;
border-top-left-radius: 15px;
-webkit-border-top-left-radius: 15px;
-moz-border-top-left-radius: 15px;
border-top-right-radius: 15px;
-webkit-border-top-right-radius: 15px;
-moz-border-top-right-radius: 15px;
border-bottom: none;
}
To style the .tab-active cases, I would create two specific rules for the sign-in and the sign-up tabs, for the right/bottom and the bottom/left borders respectively:
#tabs .tab-active{
}
#tab-signin.tab-active{
border: 1px solid #CCC;
border-width: 0 1px 1px 0;
}
#tab-signup.tab-active{
border: 1px solid #CCC;
border-width: 0 0 1px 1px;
}
See demo at: http://jsfiddle.net/audetwebdesign/By4g5/
The problem you noticed earlier is not really a browser bug. The CSS specification does not specify exactly how browsers are to draw the corners of borders (the joints), so you are at the mercy of the browser for that particular design detail.
My approach is to avoid the problem by taking full advantage of the HTML mark-up in your code.
You should probably try floats but a quick fix could be negative margins...
#tabs{
padding: 0;
margin: 0px 0px -1px 0px;
}
DEMO
EDIT: inline blocks side effects, something to read ;)
http://css-tricks.com/fighting-the-space-between-inline-block-elements/
Another solution would be if set a transparent border on class .tab-active.
just using border transparent .
#tabs .tab-active{
border-bottom: 1px solid transparent;
}
Chec the DEMO.

Resources