Nice login and signup panel Newsvine like using CSS

Are you looking for inspiration for a login panel? This post can help you...

Yesterday a reader of my blog, Benjamin, asked to me a suggest for an idea to design a simple login/register section for his site. So I suggested him to take inspiration form the panel used on Newsvine which is like the following:



It's a simple panel which includes both options (register and log-in) and it appears/disappears cliking on a link in the navigation bar. In this tutorial I prepared the code (html, css, javascript) which you can use in your HTML pages.


Download source code


Step 1: introduction
Before to go directly to the code, I want to illustrate the structure which I used to implement this panel: I added a navigation bar with an unordered list to add some links (in this tutorial I added just a link "Login | Register"), and a layer "login_menu" which contains register/login sections:



I separed the two sections using two layers #new-user-col (for register section) and #signup-user-col (for login section). Register button in the first section is a simple link with applyed CSS class .green-button; instead, Login button, in the secont section, is a <button> element which you can use to submit the login form.


Step 2: HTML code
Copy and paste the following HTML code in your page inside the tag <body>:

<div id="navbar">

<ul>
<li>
<a href=
"#" onclick="showlayer('login_menu')">
Login | Register
</a></li>
</ul>
<div id="login_menu" style="display:none;">
<div id="new-user-col">New User:<br /><br />
<a href="register.html" class="green-button">Register</a>
</div>

<div id="signup-user-col">
Existing User log in below:<br /><br />
<form action="login.html" method="post">
<ul>
<li>
<label for="email">Email:</label>
<input type="text" id="email" size="18"/>
</li>
<li>
<label for="psw">Password:</label>
<input type=
"text" id="psw" size="18"/>
</li>
<button type="submit" class="green-button">Log-in</button>
</ul>
</form>
</div>

<div class="spacer"></div>

</div>
</div>

I set the initial status of the panel to "hide", set the CSS display property of the layer "login_menu" to "none":

<div id="login_menu"style="display:none;">

Now, take a look at the CSS code...

Step 3: CSS code
Copy and paste the following CSS code in the <head> section of your page or into a separated CSS file:

/* ------------ */
/* NAV BAR */

#navbar{
background:url(pic/bg.png) repeat-x;
height:29px;
line-height:29px;
}

/*------ Reset CSS Properties ------ */
#navbar ul, #navbar li,
#navbar form,
#navbar button {
border:0; margin:0;padding:0; list-style:none;
}

#navbar li a{
margin:0 6px;
text-decoration:none;
color:#000000;
font-weight:bold;
border-bottom:dotted 1px #000000;
}

/*------ Layer with Register and Login Section ------ */
#login_menu{
background:#aaaaaa;
border:solid 1px #666666;
width:340px;
padding:10px;
color:#FFFFFF;
position:absolute;
font-weight:bold;
font-size:12px;
line-height:18px;
}
#login_menu li{
padding-bottom:6px;
text-align:right;
}
#new-user-col{
padding-right:10px;
border-right:1px #DEDEDE solid;
height:120px;
width:100px;
float:left;
line-height:12px;
}
#signup-user-col{
padding-left:20px;
height:120px;
width:200px;
float:left;
line-height:12px;
text-align:right;
}
#login_menu label{font-size:11px; font-weight:normal;}
#login_menu input{font-size:11px; color:#333333; margin-left:10px;}

/*------ Button ------ */
#login_menu button{
line-height:24px;
float:right;
color:#FFFFFF;
font-size:11px;
font-weight:bold;
text-align:center;
cursor:pointer;
}

.green-button{
background:url(pic/button.png);
display:block;
color:#FFFFFF;
font-size:11px;
text-decoration:none;
width:81px;
height:26px;
line-height:24px;
text-align:center;
}

/*------ Spacer ------ */
.spacer{clear:both; height:1px;}



Step 4: Javascript Function to show/hide layer
By showing/hiding the panel I used this simple Javascript function I often use in my tutorials:

<script type="text/javascript">
function showlayer(layer){
var myLayer = document.getElementById(layer);
if(myLayer.style.display=="none" || myLayer.style.display==""){
myLayer.style.display="block";
} else {
myLayer.style.display="none";
}
}
</script>

In the past, some readers asked to me why I don't use a framework (such as mootools, scriptaculous, jquery) to implement this effect by showing/hiding HTML elements. I could do it, but, for simplicity, I prefer to use these few lines of javascript code which I add in an external JS file.

It's all!

Download source code


Related Content
Two CSS vertical menu with show/hide effects
Pastel color menu with dynamic submenu using CSS
Digg-like navigation bar using CSS
Flickr like horizontal menu
Perfect pagination style using CSS

Description: Nice login and signup panel Newsvine like using CSS, Rating: 4.5, Reviewer: neno, ItemReviewed: Nice login and signup panel Newsvine like using CSS

0 التعليقات:

free counters

المتابعون