Expandable Search Form - html

I am working on Expandable Search but facing one problem. When i click on search bar then search bar is expanding. But right side content is moving down. I wanna hide right side content when search bar is expand similar to stackoverflow search bar.
body {
margin: 0;
padding: 0;
}
.mainheader {
width: 100%;
background-color: #FAFAFB;
border-top: 3px solid #F48024;
float: left;
padding-bottom: 10px;
-moz-box-shadow: 3px 3px 5px 1px #ccc;
-webkit-box-shadow: 3px 3px 5px 1px #ccc;
box-shadow: 3px 3px 5px 1px #ccc;
}
.innerheader {
width: 1000px;
margin: auto;
}
.logo_name {
display: inline-block;
margin-top: 13px;
line-height: 1em;
font-family: helvetica, arial, sans-serif;
font-weight: bold;
background: linear-gradient(to right, #7db9e8 50%,#1e5799 50%);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
font-size: 22px;
}
.ga_a {
float: left;
}
.ga_b {
float: left;
padding: 5px;
padding-bottom: 10px;
margin-top: 5px;
}
.ga_b ul {
margin: 0px;
padding: 0px;
margin-left: 7px;
line-height:1;
}
.ga_b ul>li {
display:inline-block;
margin-left: 5px;
padding: 5px;
}
.ga_b ul>li a {
text-decoration: none;
color: black;
font-size: 15px;
font-family: "Lucida Grande",Arial,Helvetica,Verdana,sans-serif;
}
.ga_b ul>li:hover {
background-color: #ECECEC;
}
.ga_c {
float: left;
}
.ga_c input {
outline: none;
}
.ga_c input[type=search] {
-webkit-appearance: textfield;
-webkit-box-sizing: content-box;
font-family: inherit;
font-size: 100%;
margin-left: 10px;
}
.ga_c input::-webkit-search-decoration,
.ga_c input::-webkit-search-cancel-button {
display: none;
}
.ga_c input[type=search] {
background: #ededed url(https://static.tumblr.com/ftv85bp/MIXmud4tx/search-icon.png) no-repeat 9px center;
border: solid 1px #ffffff;
padding: 9px 10px 9px 32px;
width: 175px;
border-radius: 5px;
margin-top: 5px;
-webkit-transition: all .5s;
-moz-transition: all .5s;
transition: all .5s;
}
.ga_c input[type=search]:focus {
width: 400px;
background-color: #fff;
-webkit-box-shadow: 0 0 5px rgba(109,207,246,.5);
-moz-box-shadow: 0 0 5px rgba(109,207,246,.5);
box-shadow: 0 0 5px rgba(109,207,246,.5);
}
.ga_c input:-moz-placeholder {
color: #999;
}
.ga_c input::-webkit-input-placeholder {
color: #999;
}
.ga_d {
float: left;
}
.ga_d ul>li {
display: inline-block;
display: fixed;
}
<div class="mainheader">
<div class="innerheader">
<div class="ga_a">
<a class="navbar-brand logo_name" href="#">WebSiteName</a>
</div>
<div class="ga_b">
<ul>
<li>Text One</li>
<li>Text Two</li>
<li>Text Three</li>
</ul>
</div>
<div class="ga_c">
<form>
<input type="search" placeholder="Search">
</form>
</div>
<div class="ga_d">
<ul>
<li>Login</li>
<li>Register</li>
</ul>
</div>
</div>
</div>

You can do it with the positioning:
* {box-sizing: border-box} /* recommended */
body {
margin: 0;
padding: 0;
}
.mainheader {
width: 100%;
min-width: 1000px; /* added / needs to match the .innerheader width */
margin: 0 auto; /* added */
background-color: #FAFAFB;
border-top: 3px solid #F48024;
float: left;
padding-bottom: 10px;
-moz-box-shadow: 3px 3px 5px 1px #ccc;
-webkit-box-shadow: 3px 3px 5px 1px #ccc;
box-shadow: 3px 3px 5px 1px #ccc;
}
.innerheader {
width: 1000px;
margin: 0 auto; /* modified */
}
.logo_name {
display: inline-block;
margin-top: 13px;
line-height: 1em;
font-family: helvetica, arial, sans-serif;
font-weight: bold;
background: linear-gradient(to right, #7db9e8 50%,#1e5799 50%);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
font-size: 22px;
}
.ga_a {
float: left;
}
.ga_b {
float: left;
padding: 5px;
padding-bottom: 10px;
margin-top: 5px;
}
.ga_b ul {
margin: 0;
padding: 0;
margin-left: 7px;
line-height: 1;
}
.ga_b ul>li {
display:inline-block;
margin-left: 5px;
padding: 5px;
}
.ga_b ul>li>a {
text-decoration: none;
color: #000; /*black*/
font-size: 15px;
font-family: "Lucida Grande",Arial,Helvetica,Verdana,sans-serif;
}
.ga_b ul>li:hover {
background: #ECECEC;
}
.ga_c {
position: relative; /* needs to be set because of the absolute positioned child */
float: left;
}
.ga_c input {
outline: none;
}
.ga_c input[type=search] {
position: absolute; /* needs to be positioned absolutely, i.e. be removed from the normal document flow so that it can "overlay" and other element, of course the z-index needs to be set */
z-index: 9999; /* usually something big just to be sure it stays on top / in front of everything else */
-webkit-appearance: textfield;
-webkit-box-sizing: content-box;
font-family: inherit;
font-size: 100%;
margin-left: 10px;
}
.ga_c input::-webkit-search-decoration,
.ga_c input::-webkit-search-cancel-button {
display: none;
}
.ga_c input[type=search] {
background: #ededed url(https://static.tumblr.com/ftv85bp/MIXmud4tx/search-icon.png) no-repeat 9px center;
border: solid 1px #fff;
padding: 9px 10px 9px 32px;
width: 175px;
border-radius: 5px;
margin-top: 5px;
-webkit-transition: all .5s;
-moz-transition: all .5s;
transition: all .5s;
}
.ga_c input[type=search]:focus {
width: 400px;
background-color: #fff;
-webkit-box-shadow: 0 0 5px rgba(109,207,246,.5);
-moz-box-shadow: 0 0 5px rgba(109,207,246,.5);
box-shadow: 0 0 5px rgba(109,207,246,.5);
}
.ga_c input:-moz-placeholder {
color: #999;
}
.ga_c input::-webkit-input-placeholder {
color: #999;
}
.ga_d {
position: relative; /* positioned relative to its normal position so that we can move it with "directional" properties */
left: 229px; /* moved to the right by the width of the .ga_c (inspected the element) */
float: left;
}
.ga_d ul>li {
display: inline-block;
display: fixed;
}
<div class="mainheader">
<div class="innerheader">
<div class="ga_a">
<a class="navbar-brand logo_name" href="#">WebSiteName</a>
</div>
<div class="ga_b">
<ul>
<li>Text One</li>
<li>Text Two</li>
<li>Text Three</li>
</ul>
</div>
<div class="ga_c">
<form>
<input type="search" placeholder="Search">
</form>
</div>
<div class="ga_d">
<ul>
<li>Login</li>
<li>Register</li>
</ul>
</div>
</div>
</div>

With your structure, it is not possible using css only. However if change the structure you could have something like this.
*{
box-sizing: border-box;
font-family: arial;
}
input{
padding: 10px;
background: #eee;
border: 1px solid #ddd;
display: inline-block;
transition: .3s;
margin-right: 10px;
width: 250px;
}
input:focus{
width: 400px;
}
input:focus + div{
opacity: 0;
visibility: hidden;
}
ul{
padding: 0;
margin: 0;
}
ul li{
display: inline;
margin-right: 5px;
}
div {
display: inline-block;
transition: .3s;
}
<input type="search" placeholder="Search">
<div class="ga_d">
<ul>
<li>Login</li>
<li>Register</li>
</ul>
</div>

Related

How to align articles on HTML5

I am creating a website for my school coding class using Adobe Dreamweaver, but I have run into an issue.
I have two articles and am trying to get them inline. They are both set to block, and I know that they should be inline-block elements, but setting it to that causes a problem.
I have a navigation bar above these two articles, and if I make these articles inline-block elements, it makes the navigation bar disappear. I don't know why this is happening, and have tried asking my teacher and classmates for help, but can't find a solution. Here is an image of what it looks like with both articles as block elements:
This is what it looks like when they are inline-block elements:
I want the articles to be together, as shown in the second image, but I still want to keep my navigation bar. Note that the navigation bar is styled with 'position:fixed', so that it always stays at the top of my page. I also want to keep this, but I feel as though it may be the cause for my problem. Here is a snippet of the code which I made (sorry if it doesn't work properly, and that the images don't work)
#import url('https://fonts.googleapis.com/css2?family=Limelight&display=swap');
#import url('https://fonts.googleapis.com/css2?family=Zen+Dots&display=swap');
nav {
height: 120px;
background-color: black;
width: 100%;
display: block;
margin: -130px 0 0 -10px;
position: fixed;
}
.dropdown {
padding-right: 5px;
margin-right: 5px;
}
.tasa {
text-transform: uppercase;
font-family: 'Limelight', cursive;
}
.nav-bar-image {
width: 110px;
height: 100px;
margin: 10px -10px 10px 10px;
display: inline;
}
nav>ul>li>a {
text-decoration: none;
color: white;
}
nav>ul>li {
font-size: 20px;
font-family: Zen Dots;
display: inline;
padding: 10px;
}
nav>ul>li:hover {
background-color: darkgrey;
}
nav>ul>li>ul {
display: none;
margin-top: 10px;
font-size: 14px;
margin-left: 165px;
list-style-type: none;
position: absolute;
}
nav>ul>li:hover>ul {
display: block;
}
nav>ul>li>ul>li {
padding-left: 10px;
padding-right: 69.5px;
}
nav>ul>li>ul>li:hover {
background-color: darkgrey;
}
nav>ul>li>ul>li>a {
color: white;
text-decoration: none;
}
nav>ul {
display: inline-block;
vertical-align: top;
margin-top: 20px;
list-style-type: none;
}
body {
background-image: url(background.jpg);
}
article {
background-color: rgba(255, 231, 179, 0.80);
width: 400px;
margin: 130px 0 0 10px;
/*130px 0 0 10px*/
padding: 5px 10px 10px;
height: 200px;
text-align: justify;
height: 750px;
display: block;
verticle-align: top;
}
.left {
border-top-left-radius: 50px;
border-bottom-left-radius: 50px;
height: 200px;
}
.centre {
margin-top: 0;
height: 200px;
}
h1 {
color: white;
font-family: Limelight;
font-size: 40px;
text-align: center;
margin: 10px 0 0;
}
p {
text-align: jusify;
color: white;
}
article>ul>li>a {
color: white;
text-decoration: none;
}
article>ul {
list-style-type: none;
}
::-webkit-scrollbar {
width: 16px;
}
::-webkit-scrollbar-thumb {
background: #ffe7b3;
border-radius: 8px;
}
::-webkit-scrollbar-track {
background: #ffffff;
box-shadow: inset 0 0 5px grey;
border-radius: 8px;
}
/*
::-webkit-scrollbar-button:single-button {
background-color: #ffffff;
display: block;
border-style: solid;
height: 13px;
width: 16px;
}
*/
::-webkit-scrollbar-thumb:hover {
background: #d6c39a;
}
/*
::-webkit-scrollbar-button:single-button:vertical:decrement {
border-width: 0 8px 8px 8px;
border-color: transparent transparent #000000 transparent;
}
::-webkit-scrollbar-button:single-button:vertical:decrement:hover {
border-color: transparent transparent #5e5e5e transparent;
}
::-webkit-scrollbar-button:single-button:vertical:increment {
border-width: 8px 8px 0 8px;
border-color: #000000 transparent transparent transparent;
}
::-webkit-scrollbar-button:vertical:single-button:increment:hover {
border-color: #5e5e5e transparent transparent transparent;
}
*/
html {
cursor: url(tasa-cursor-medium.cur), default;
}
a {
cursor: url(tasa-cursor-a-large.cur), default;
}
<header>
<nav>
<img src="logo.jpg" alt="TASA logo." class="nav-bar-image">
<ul>
<li>Home</li>
<li>Details</li>
<li class="dropdown">Presentations
<ul>
<li>Introduction</li>
<li>Constellations</li>
<li>Lunar Events</li>
</ul>
</li>
<li>Links</li>
</ul>
</nav>
</header>
<article class="left">
<h1>TASA</h1>
<p>
</p>
</article>
<article class=centre>
<h1>Images</h1>
</article>
This snippet has the display element on the articles set to block, not inline-block.
The problem: when you make the class left and centre inline-block, the margin-top of the nav is -130px. This makes it go out of screen.
A more clean solution would be to use flex box, and have some flexibility ;) of the alignment of items. In the solution, i removed the margin and changed it, see below:
/* Wrap the class "left" and "centre" with a div (i named it "main_content") */
.main_content {
display: flex;
flex-direction: row;
}
nav {
/* Removed this -> margin: -130px 0 0 -10px; */
position: fixed;
}
.centre {
/* Removed this --> margin-top: 0; */
}
nav>ul {
/* Changed margin-top from 20px to 0px */
margin-top: 0px;
}
#import url('https://fonts.googleapis.com/css2?family=Limelight&display=swap');
#import url('https://fonts.googleapis.com/css2?family=Zen+Dots&display=swap');
nav {
height: 120px;
background-color: black;
width: 100%;
display: block;
position: fixed;
}
.dropdown {
padding-right: 5px;
margin-right: 5px;
}
.tasa {
text-transform: uppercase;
font-family: 'Limelight', cursive;
}
.nav-bar-image {
width: 110px;
height: 100px;
margin: 10px -10px 10px 10px;
display: inline;
}
nav>ul>li>a {
text-decoration: none;
color: white;
}
nav>ul>li {
font-size: 20px;
font-family: Zen Dots;
display: inline;
padding: 10px;
}
nav>ul>li:hover {
background-color: darkgrey;
}
nav>ul>li>ul {
display: none;
margin-top: 10px;
font-size: 14px;
margin-left: 165px;
list-style-type: none;
position: absolute;
}
nav>ul>li:hover>ul {
display: block;
}
nav>ul>li>ul>li {
padding-left: 10px;
padding-right: 69.5px;
}
nav>ul>li>ul>li:hover {
background-color: darkgrey;
}
nav>ul>li>ul>li>a {
color: white;
text-decoration: none;
}
nav>ul {
display: inline-block;
vertical-align: top;
margin-top: 0px;
list-style-type: none;
}
body {
background-image: url(background.jpg);
}
article {
background-color: rgba(255, 231, 179, 0.80);
width: 400px;
margin: 130px 0 0 10px;
/*130px 0 0 10px*/
padding: 5px 10px 10px;
height: 200px;
text-align: justify;
height: 750px;
display: block;
vertical-align: top;
}
.main_content {
display: flex;
flex-direction: row;
}
.left {
border-top-left-radius: 50px;
border-bottom-left-radius: 50px;
height: 200px;
}
.centre {
height: 200px;
}
h1 {
color: white;
font-family: Limelight;
font-size: 40px;
text-align: center;
margin: 10px 0 0;
}
p {
text-align: jusify;
color: white;
}
article>ul>li>a {
color: white;
text-decoration: none;
}
article>ul {
list-style-type: none;
}
::-webkit-scrollbar {
width: 16px;
}
::-webkit-scrollbar-thumb {
background: #ffe7b3;
border-radius: 8px;
}
::-webkit-scrollbar-track {
background: #ffffff;
box-shadow: inset 0 0 5px grey;
border-radius: 8px;
}
/*
::-webkit-scrollbar-button:single-button {
background-color: #ffffff;
display: block;
border-style: solid;
height: 13px;
width: 16px;
}
*/
::-webkit-scrollbar-thumb:hover {
background: #d6c39a;
}
/*
::-webkit-scrollbar-button:single-button:vertical:decrement {
border-width: 0 8px 8px 8px;
border-color: transparent transparent #000000 transparent;
}
::-webkit-scrollbar-button:single-button:vertical:decrement:hover {
border-color: transparent transparent #5e5e5e transparent;
}
::-webkit-scrollbar-button:single-button:vertical:increment {
border-width: 8px 8px 0 8px;
border-color: #000000 transparent transparent transparent;
}
::-webkit-scrollbar-button:vertical:single-button:increment:hover {
border-color: #5e5e5e transparent transparent transparent;
}
*/
html {
cursor: url(tasa-cursor-medium.cur), default;
}
a {
cursor: url(tasa-cursor-a-large.cur), default;
}
<header>
<nav>
<img src="logo.jpg" alt="TASA logo." class="nav-bar-image">
<ul>
<li>Home</li>
<li>Details</li>
<li class="dropdown">Presentations
<ul>
<li>Introduction</li>
<li>Constellations</li>
<li>Lunar Events</li>
</ul>
</li>
<li>Links</li>
</ul>
</nav>
</header>
<div class="main_content">
<article class="left">
<h1>TASA</h1>
<p>
</p>
</article>
<article class="centre">
<h1>Images</h1>
</article>
</div>

How to make Search form in navigation bar fill the space between two div elements?

I'm trying to make a navigation bar in which the search form will always fill the space between the left and right part/divs of the navigation bar, one example of such a search form would be Amazon.
I've tried multiple approaches for the last two hours yet the search bar doesn't seem to want to change width unless I set it manually.
The full code:
http://jsfiddle.net/asoctyk9/
The HTML:
<nav>
<ul>
<div class="navbar-main-wrapper">
<div class="navbar-left-wrapper">
<li><a href="/" >Home</a></li>
<li><a href="profile" >My Account</a></li>
<li><a href="contact" >Contact</a></li>
</div>
<div class="navbar-right-wrapper">
<li>Sign In</li>
<li>Register</li>
<li>Logout</li>
<script>
//...
</script>
<li>About</li>
</div>
<!-- MIDDLE FILL -->
<div class="navbar-search-wrapper">
<li>
<form action="/search" id="searchform" method="GET">
<input type="search" name="search" placeholder="What are you looking for..." />
<button type="submit" form="searchform"><i class="fa fa-search"></i></button>
</form>
</li>
</div>
</div>
</ul>
</nav>
The CSS:
nav {
margin-bottom: 30px;
}
nav ul{
list-style-type: none;
margin: 0px;
padding: 0px;
/*overflow: hidden;*/
background-color: #232f3e;
height: 47px;
padding-bottom: 5px;
}
nav li {
display: inline-block;
padding-right: 2px;
padding-left: 2px;
}
nav .navbar-left-wrapper {
padding-left: 10%;
float: left;
}
nav .navbar-right-wrapper {
float: right;
padding-right: 10%;
}
nav .navbar-main-wrapper {
margin: 0 auto;
max-width: 1460px;
min-width: 1100px;
}
nav li a {
display: block;
color: white;
/*text-align: center;*/
padding: 14px 16px;
text-decoration: none;
font-family: Arial, Helvetica, sans-serif;
border-radius: 10%;
}
nav li a:hover:not(.active) {
background-color: #485769;
}
nav li a#nav-logout:hover:not(.active) {
background-color: rgb(221, 34, 34);
}
nav a.active {
background-color: #586a80;
}
nav input[type=search] {
height: 40px;
font-size: 16px;
background-color: none;
padding: 10px 20px 10px 20px;
display: inline-block;
border-top-left-radius: 3px;
border-bottom-left-radius: 3px;
box-sizing: border-box;
background-color: #ffffff;
box-shadow: 0 1px 0 0 rgba(255, 255, 255, 0.1);
border:none;
resize:none;
margin: 4px 0px 4px 0px;
font: inherit;
font-size: 14px;
font-weight: normal;
padding: 10px;
}
nav input[type=search]:focus {
outline: none;
}
nav .navbar-search-wrapper {
display: inline-block;
/*border: 2px solid red;*/
}
nav .navbar-search-wrapper button {
float: right;
padding: 10px 10px;
margin-top: 4px;
background: #ffa807;
font-size: 17px;
border: none;
cursor: pointer;
border-top-right-radius: 3px;
border-bottom-right-radius: 3px;
}
nav .navbar-search-wrapper button:hover {
background: #ff8808;
}
When I zoom out the page the search bar goes to the left. I'd like it to "stick" to the first element of navbar-right-wrapper and last of navbar-left-wrapper and expand while the user zooming out the page, basically always filling the space between links.
I'm just starting out with HTML and CSS so any help with this would be greatly appreciated!
Edit: added CSS code
There is some HTML and CSS changes. Please use below code.
HTML Code :
<nav>
<div class="nav_my_main">
<div class="navbar-main-wrapper">
<ul class="navbar-left-wrapper">
<li><a href="/" >Home</a></li>
<li><a href="profile" >My Account</a></li>
<li><a href="contact" >Contact</a></li>
</ul>
<ul class="navbar-right-wrapper">
<li>Sign In</li>
<li>Register</li>
<!--{{#if auth}}
<script>
console.log(this)
var register = document.getElementById('nav-register');
register.style.visibility = 'hidden';
register.style.position = 'absolute';
</script>
{{/if}} -->
<li>Logout</li>
<script>
function logoutConfirm() {
var r = confirm('Are you sure you want to log out?');
//if the user clicks "Cancel" on the pop-up, user doesn't logout
if (r !== true) {
event.preventDefault();
}
}
</script>
<li>About</li>
</ul>
<!-- MIDDLE FILL -->
<ul class="navbar-search-wrapper">
<li>
<form action="/search" id="searchform" method="GET">
<input type="search" name="search" placeholder="What are you looking for..." />
<button type="submit" form="searchform"><i class="fa fa-search"></i></button>
</form>
</li>
</ul>
</div>
</div>
</nav>
CSS Code
/* ==== START NAVIGATION BAR ==== */
nav {
margin-bottom: 30px;
}
nav .nav_my_main{
list-style-type: none;
margin: 0px;
padding: 0px;
/*overflow: hidden;*/
background-color: #232f3e;
height: 47px;
padding-bottom: 5px;
}
nav li {
display: inline-block;
padding-right: 2px;
padding-left: 2px;
}
nav .navbar-left-wrapper {
padding-left: 0;
float: left;
width: 300px;
}
nav .navbar-right-wrapper {
float: right;
padding-right: 0;
width: 275px;
}
nav .navbar-main-wrapper {
margin: 0 auto;
max-width: 1460px;
min-width: 1100px;
margin: 0px;
padding: 0px;
background-color: #232f3e;
height: 47px;
padding-bottom: 5px;
display: block;
width: 100%;
}
nav li a {
display: block;
color: white;
/*text-align: center;*/
padding: 14px 16px;
text-decoration: none;
font-family: Arial, Helvetica, sans-serif;
border-radius: 10%;
}
nav li a:hover:not(.active) {
background-color: #485769;
}
nav li a#nav-logout:hover:not(.active) {
background-color: rgb(221, 34, 34);
}
nav a.active {
background-color: #586a80;
}
/* ==============SEARCH BAR============== */
nav .navbar-search-wrapper li{
width:100%;
}
nav input[type=search] {
height: 40px;
font-size: 16px;
background-color: none;
padding: 10px 20px 10px 20px;
/*-webkit-transition: width 0.4s ease-in-out;
transition: width 0.4s ease-in-out;*/
/*center element using parent text-align:center and child display:inline-block; */
display: inline-block;
border-top-left-radius: 3px;
border-bottom-left-radius: 3px;
box-sizing: border-box;
background-color: #ffffff;
box-shadow: 0 1px 0 0 rgba(255, 255, 255, 0.1);
border:none;
margin: 4px 0px 4px 0px;
font-size: 14px;
font-weight: normal;
padding: 10px;
width: calc(100% - 36px);
}
nav input[type=search]:focus {
outline: none;
}
nav .navbar-search-wrapper {
display: inline-block;
width: calc(100% - 615px);
padding-left: 0;
margin: 2px auto;
/*border: 2px solid red;*/
}
nav .navbar-search-wrapper button {
float: right;
padding: 10px 10px;
margin-top: 4px;
background: #ffa807;
font-size: 17px;
border: none;
cursor: pointer;
border-top-right-radius: 3px;
border-bottom-right-radius: 3px;
height: 40px;
width: 36px;
}
nav .navbar-search-wrapper button:hover {
background: #ff8808;
}
/* ==============END SEARCH BAR============== */
/* ==== END NAVIGATION BAR ==== */
You may be looking something like this, perhaps?
Just wrap all inside a ul tag then just give ul display: flex, and put percentage unit for the li that's wrapping the search form.
ul {
list-style: none;
background: dray;
width: 100%;
font-size: 0;
padding: 0;
margin: 0;
display: flex;
}
li {
font-size: 15px;
display: inline-block;
border: 1px solid rgba(0,0,0,.5);
padding: 10px;
}
li.search-form {
width: 100%;
font-size: 0;
}
li.search-form input[type="search"] {
width: 80%;
font-size: 15px;
}
li.search-form input[type="submit"] {
width: 20%;
}
<ul>
<li>Home</li>
<li>My Account</li>
<li>Contact</li>
<li class="search-form">
<form>
<input type="search">
<input type="submit">
</form>
</li>
<li>Sign In</li>
<li>Register</li>
<li>Logout</li>
<li>About</li>
</ul>
Please add this css
#searchform {
height: 40px;
padding: 0px 15px;
display: inline-block;
box-sizing: border-box;
background-color: #ffffff;
box-shadow: 0 1px 0 0 rgba(255, 255, 255, 0.1);
border: none;
resize: none;
margin: 4px 0px;
font: inherit;
font-size: 14px;
font-weight: normal;
position: relative;
border-radius: 5px;
overflow: hidden;
}
#searchform input[type=search] {
height: 38px;
border: 0;
}
nav .navbar-search-wrapper button {
float: right;
margin: auto;
background: #ffa807;
font-size: 17px;
border: none;
cursor: pointer;
position: absolute;
right: 0;
bottom: 0;
top: 0;
text-align: center;
padding: 10px;
}
and remove this:
nav input[type=search] {
height: 40px;
font-size: 16px;
background-color: none;
padding: 10px 20px 10px 20px;
display: inline-block;
border-top-left-radius: 3px;
border-bottom-left-radius: 3px;
box-sizing: border-box;
background-color: #ffffff;
box-shadow: 0 1px 0 0 rgba(255, 255, 255, 0.1);
border: none;
resize: none;
margin: 4px 0px 4px 0px;
font: inherit;
font-size: 14px;
font-weight: normal;
padding: 10px;
}

A border is adding to a HTML element's width (only on one side) for no reason I can see

I'm trying to create this price column, and have been modifying the code of a tutorial, and everything was going fine until I added a border to .price section of it. The border added some extra width to the element, but only on the right side. I tried to see if another div was the reason, or some forgotten about margin/padding values with Chrome Dev Tools, but I can't see anything.
I would really appreciate any help with finding out what is causing the extra width to .price div
Here is the html:
<ul class="pricing_table">
<li></li>
<li class="price_block">
<h3>Web Development</h3>
<div class="price">
<div class="price_figure">
<span class="price_number">$9.99</span>
<span class="price_tenure">per month</span>
</div>
</div>
<ul class="features">
<li>2GB Storage</li>
<li>5 Clients</li>
<li>10 Active Projects</li>
<li>Free Goodies</li>
<li>24/7 Email support</li>
</ul>
<div class="buynow">
Buy Now
</div>
</li>
</ul>
Here is the CSS:
* {
margin: 0;
padding: 0;
}
li {
list-style:none;
}
body {
font-family: roboto;
}
h3 {
font-family: lato;
}
.pricing_table {
line-height: 150%;
font-size: 20px;
margin: 0 auto;
width: 75%;
max-width: 400px;
padding-top: 10px;
margin-top: 100px;
}
.price_block, .price_block_blue {
width: 100%;
color: black;
background-color: white;
float: left;
list-style-type: none;
transition: all 0.25s;
position: relative;
box-sizing: border-box;
margin-bottom: 10px;
}
.pricing_table h3 {
text-transform: uppercase;
padding: 5px 0;
background: white;
margin: -10px 0 0 0;
text-align: center;
border: 3px solid black;
border-bottom: 0px solid transparent;
}
.price {
display: table;
background: red;
width: 100%;
margin: 0;
padding: 0;
height: 70px;
text-align: center;
border: 3px solid black;
border-top:0px solid black;
border-bottom:0px solid black;
}
.price_blue {
display: table;
background: blue;
width: 100%;
height: 70px;
text-align: center;
}
.price_figure {
font-size: 24px;
text-transform: uppercase;
vertical-align: middle;
display: table-cell;
}
.price_number {
font-weight: bold;
padding: 10px 0 0 0;
display: block;
}
.price_tenure {
font-size: 11px;
}
.features {
background: #fff;
color: #000;
text-align: center;
border: 3px solid black;
border-bottom: 0px solid transparent;
border-top: 0px solid transparent;
}
.features li {
padding: 8px 15px;
border-bottom: 1px solid #ccc;
font-size: 11px;
list-style-type: none;
}
.buynow {
padding: 15px;
background: white;
text-align: center;
border: 3px solid black;
border-top: 0px solid black;
}
.action_button {
text-decoration: none;
color: white;
font-weight: bold;
border-radius: 5px;
background: red;
padding: 5px 20px;
font-size: 11px;
text-transform: uppercase;
}
.price_block:hover,.price_block_blue:hover {
box-shadow: 0 0 0px 5px rgba(0, 0, 0, 0.5);
transform: scale(1.04) translateY(-5px);
z-index: 1;
border-bottom: 0 none;
}
.price_block:hover .price {
background: yellow;
/*box-shadow: inset 0 0 45px 1px #ADD8E6;*/
}
.price_block_blue:hover .price_blue {
background: yellow;
}
.price_block:hover h3{
background: black;
color: white;
}
.price_block_blue:hover h3 {
background: black;
color: white;
}
.price_block:hover .action_button, .price_block_blue:hover .action_button {
background: linear-gradient(#F9B84A, #DB7224);
}
Since you are adding a border, it gets added to your overall width. So the actual width of .price is 100% + 3px (left border) + 3px (right border). To have the total width include padding and borders, use box-sizing:
.price {
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}

How to prevent unwanted elements from moving on hover in CSS?

In the organization chart below, when you hover over an element in A, B or C column, there is a weird thing happening. The lines and boxes after hovered element are moving down as the hovered element is changing size, but after it has finished resizing, those lines and boxes return to previous position. (I want to keep this position always, even during resizing of an hovering element)
Can anyone help me fix this?
Code:
*{
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
position: relative;
-webkit-transition: all linear 1s;
-moz-transition: all linear 1s;
transition: all linear 1s;
}
.tree{
width: 50%;
max-width: 1000px;
margin: 0 auto;
padding: 10px 20px;
}
ul{
list-style: none;
padding: 0;
}
ul a{
display: block;
background: #ccc;
border: 2px solid #000;
text-align: center;
font: bold 11px "Times New Roman", Times, serif;
text-decoration: none;
height: 90px;
box-shadow: 5px 5px 10px -5px rgba(0,0,0,0.5);
}
img {
width: 29%;
height: 80px;
float: left;
margin: 3px 0 0 6px;
border: 1px solid #FFF;
border-radius: 5px;
}
a:hover{
font: bold 11.5px "Times New Roman", Times, serif;
}
a:hover span{
font-size: 16px;
}
a:hover > img{
width: 30%;
height: 90px;
}
.tree span{
font-size: 15px;
}
.leader{
width: 35%;
margin: 0 auto;
}
.leader:after{
content: "";
display: block;
height: 60px;
border-left: 2px solid #000;
margin: 0 0 -20px 50%;
}
.leader a{
margin: 0 auto;
border-radius: 10px;
width: 85%;
}
.leader a:hover{
box-shadow: 8px 8px 9px -4px rgba(0,0,0,0.1);
height: 100px;
width: 90%;
margin: -10px auto 0 auto;
}
.teams{
margin-left: -3%;
}
.teams li{
float: left;
width: 30.3%;
margin-left: 3%;
}
.teams:after{
content: "";
display: block;
width: 66.5%;
height: 20px;
border-top: 2px solid #000;
border-right: 2px solid #000;
border-left: 2px solid #000;
margin-left: 18%;
}
.team li{
margin: 0 auto;
}
.team a{
height: 35px;
margin-top: 20px;
}
.team li a{
margin-left: 10%;
}
.team > a:first-child{
pointer-events: none;
}
.employees li{
float: none;
width: 100%;
}
.employees li:before{
content: "";
display: block;
height: 60px;
border-left: 2px solid #000;
border-bottom: 2px solid #000;
width: 9%;
}
.employees li:nth-child(1n+2):before{
height: 100px;
margin-top: -43px;
}
.employees li a{
width: 90%;
height: 90px;
border-radius: 10px;
margin-top: -47px;
z-index: 1;
}
.employees li a:hover{
box-shadow: 8px 8px 9px -4px rgba(0,0,0,0.1);
height: 100px;
width: 95%;
margin: -52px 0 -48px 5%;
}
<body ondragstart="return false">
<div class="tree">
<ul>
<li class="leader">Leader</li>
<ul class="teams">
<li class="team a">A
<ul class="employees">
<li>A1</li>
<li>A2</li>
<li>A3</li>
<li>A4</li>
</ul>
</li>
<li class="team b">B
<ul class="employees">
<li>B1</li>
<li>B2</li>
</ul>
</li>
<li class="team c">C
<ul class="employees">
<li>C1</li>
<li>C2</li>
<li>C3</li>
</ul>
</li>
</ul>
</ul>
</div>
</body>
I would suggest using transform:scale(x) for the hover effect instead of actually changing the element size. Transform does not affect the overall layout so the surrounding elements stay where they are. Also transforms don't cause the browser to repaint and can use the GPU for the animating process so they are generally much smoother.

DIV list links refuse to touch

My links are not Start Class and Center class for my website I am building. I have gone over this several times and can not see what I have done wrong. Can someone please assist me with this?
My html
<DIV class="outline">
<DIV class="navigation">
<ul>
<li class="orange start">Home</li>
<li class="orange center">Forum</li>
</ul>
</DIV>
</DIV>
My Css class
/*Start Links*/
a:link {
color: #FFFFFF;
text-decoration: none;
margin: 0;
}
a:visited {
color: #FFFFFF;
text-decoration: none;
}
a:hover {
color: #FFFFFF;
text-decoration: none;
}
a:active {
color: #FFFFFF;
text-decoration: none;
}
.navigation ul li {
margin: 0px auto;
display: inline-block;
}
/*End Links*/
/*Start Button*/
.start {
display: inline-block;
outline: none;
cursor: pointer;
text-align: center;
text-decoration: none;
font: 14px/100% Arial, Helvetica, sans-serif;
padding: .5em 2em .55em;
text-shadow: 0 1px 1px rgba(0,0,0,.3);
-webkit-border-radius: .5em 0 0 .5em;
-moz-border-radius: .5em 0 0 .5em;
border-radius: .5em 0 0 .5em;
-webkit-box-shadow: 0 1px 2px rgba(0,0,0,.2);
-moz-box-shadow: 0 1px 2px rgba(0,0,0,.2);
box-shadow: 0 1px 2pxrgba(0,0,0,.2);
margin: 0px;
}
.center {
display: inline-block;
outline: none;
cursor: pointer;
text-align: center;
text-decoration: none;
font: 14px/100% Arial, Helvetica, sans-serif;
padding: .5em 2em .55em;
text-shadow: 0 1px 1px rgba(0,0,0,.3);
-webkit-border-radius: 0;
-moz-border-radius: 0;
border-radius: 0;
-webkit-box-shadow: 0 1px 2px rgba(0,0,0,.2);
-moz-box-shadow: 0 1px 2px rgba(0,0,0,.2);
box-shadow: 0 1px 2pxrgba(0,0,0,.2);
margin: 0;
}
.button {
display: inline-block;
outline: none;
cursor: pointer;
text-align: center;
text-decoration: none;
font: 14px/100% Arial, Helvetica, sans-serif;
padding: .5em 2em .55em;
text-shadow: 0 1px 1px rgba(0,0,0,.3);
-webkit-border-radius: .5em;
-moz-border-radius: .5em;
border-radius: .5em;
-webkit-box-shadow: 0 1px 2px rgba(0,0,0,.2);
-moz-box-shadow: 0 1px 2px rgba(0,0,0,.2);
box-shadow: 0 1px 2pxrgba(0,0,0,.2);
}
.button:hover {
text-decoration: none;
}
.button:active {
position: relative;
top: 1px;
}
.orange {
color: #fef4e9;
border: solid 1px #da7c0c;
background: #f78d1d;
background: -webkit-gradient(linear, left top, left bottom, from(#faa51a), to(#f47a20));
background: -moz-linear-gradient(top, #faa51a, #f47a20);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#faa51a', endColorstr='#f47a20');
}
.orange:hover {
background: #f47c20;
background: -webkit-gradient(linear, left top, left bottom, from(#f88e11), to(#f06015));
background: -moz-linear-gradient(top, #f88e11, #f06015);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#f88e11', endColorstr='#f06015');
}
.orange:active {
color: #fcd3a5;
background: -webkit-gradient(linear, left top, left bottom, from(#f47a20), to(#faa51a));
background: -moz-linear-gradient(top, #f47a20, #faa51a);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#f47a20', endColorstr='#faa51a');
}
/*End Button*/
/*Start Website*/
body {
background-color: #393939;
color: #FFFFFF;
padding: 0;
margin: 0;
}
.header {
display: inline-block;
width: 100%;
text-align: left;
border:solid 2px red;
}
.circle {
float: left;
width: 100px;
height:100px;
display: inline-block;
background: #FF5A09;
-webkit-border-radius: 50%;
-moz-border-radius: 50%;
border-radius: 50%;
}
.header h1.first {
margin-top: 30px;
margin-left: -92px;
margin-right: 5px;
display: inline-block;
color: #FFFFFF;
}
.header h1.last {
display: inline;
color: #FF5A09;
}
.header .right {
display: block;
height: auto;
float: right;
padding: 10px 10px 10px 10px;
border-left: solid 2px red;
}
.navigation {
margin: 0 auto;
display: inline-block;
width: 100%;
text-align: center;
}
.outline {
display: block;
margin: 0 auto;
width: 980px;
border: solid 2px red;
}
.content {
display: inline-block;
width: 60%;
border: solid 2px red;
margin: 0 auto;
}
.footer {
display: block;
width: 100%;
border: solid 2px red;
padding: 10px 0 10px 0;
text-align: center;
}
/*End Website*/
/*Start slider*/
/*End slider*/
It is because the whitespace between the <li> elements is significant. If you remove all whitespace, the elements will be right next to each other. Either you just do this:
<li class="orange start">Home</li><li class="orange center">Forum</li>
Or, if you want to keep the line breaks in code, which I usually think is a good thing, you can insert an HTML comment like this:
<li class="orange start">Home</li><!--
--><li class="orange center">Forum</li>
It's a matter of taste, but I tend to favor the latter because I find it more readable.