How to make.
.l {
float: left
}
.abs {
position: absolute
}
.rl {
position: relative
}
.r {
float: right
}
.f {
clear: both
}
.menuItem {
border-bottom: 1px #ccc solid
}
.menuItem .p {
padding: 10px 10px;
font-weight: bold;
font-size: 12px
}
.menuItem .active {
color: #333;
cursor: default
}
.menuItem a {
display: block;
text-decoration: none;
cursor: pointer
}
.menuItem .p:hover {
background-color: #f5f5f6;
text-decoration: none
}
<div class='menuItem'>
<div class='l' style='margin-left:120px'> </div>
<div class='l p active'>Info
</div>
<a href="<% $URL %><% $_GET[0] %>/forums">
<div class='l p'>Forums (105)</div>
</a>
<div class='f'></div>
</div>
http://jsfiddle.net/AndyPSV/6gh2dfm4/1/
Image under (center position) .active as such:
(white background, consistent with the border_bottom)
and background: #fff when you hover on ALL active?
An easy solution would be to create a small image of a triangle and to use the background css property on the class .active to position that image in the middle of the bottom. When hovering over the .active you can set the background to none. For example:
.active {
background: url('http://placehold.it/9x9') center bottom no-repeat;
}
.active:hover {
background: none;
}
Another option might be not to use an image at all and to use create a triangle in a :after selector using css.
.l {
float: left
}
.abs {
position: absolute
}
.rl {
position: relative
}
.r {
float: right
}
.f {
clear: both
}
.menuItem {
border-bottom: 1px #ccc solid
}
.menuItem .p {
padding: 10px 10px;
font-weight: bold;
font-size: 12px
}
.menuItem .active {
color: #333;
cursor: default
}
.menuItem a {
display: block;
text-decoration: none;
cursor: pointer
}
.menuItem .p:hover {
background-color: #f5f5f6;
text-decoration: none
}
.active {
background: url('http://placehold.it/9x9') center bottom no-repeat;
}
.active:hover {
background: none;
}
<div class='menuItem'>
<div class='l' style='margin-left:120px'> </div>
<div class='l p active'>Info
</div>
<a href="<% $URL %><% $_GET[0] %>/forums">
<div class='l p'>Forums (105)</div>
</a>
<div class='f'></div>
</div>
you can use :pseudo element for adding triangle at the bottom
.l {
float: left;
position: relative;
}
.abs {
position: absolute
}
.rl {
position: relative
}
.r {
float: right
}
.f {
clear: both
}
.menuItem {
border-bottom: 1px #ccc solid
}
.menuItem .p {
padding: 10px 10px;
font-weight: bold;
font-size: 12px
}
.menuItem .active {
color: #333;
cursor: default
}
.menuItem a {
display: block;
text-decoration: none;
cursor: pointer
}
.menuItem .p:hover {
background-color: #f5f5f6;
text-decoration: none
}
.l.active:after {
content: '';
bottom: -1px;
width: 0;
height: 0;
position: absolute;
border-style: solid;
border-width: 0px 9px 10px 9px;
border-color: rgb(233, 234, 237) transparent;
left: 50%;
margin-left: -11px;
}
.l.active:before {
content: '';
bottom: -1px;
width: 0;
height: 0;
position: absolute;
border-style: solid;
border-width: 0px 10px 11px 10px;
border-color: #ccc transparent;
left: 50%;
margin-left: -12px;
}
<div class='menuItem'>
<div class='l' style='margin-left:120px'> </div>
<div class='l p active'>Info
</div>
<a href="<% $URL %><% $_GET[0] %>/forums">
<div class='l p'>Forums (105)</div>
</a>
<div class='f'></div>
</div>
Related
I modified 3 different peoples code to make css arrows and I think I made it more complicated than it needs to be. Any CSS expert than can help me clean this up?
I can't seem to modify padding and other attributes to get this where I want it within the divs.
css
<style>
/* These are the Stage Arrows - styles */
#testStatus {
position: relative;
width: auto;
height: 30px;
left: 10px;
}
.testStatus li {
position: relative;
text-indent: 10px;
height: 30px;
display: inline-block;
zoom: 1;
margin-left: -3px;
padding: 10px 10px 10px 10px;
color: white;
font-size: 12px;
text-align: center;
line-height: auto;
}
ul.testStatus {
list-style: none;
}
li.testStatus:first-child:after, li.testStatusGood:after, li.testStatusNoGood:after {
content: "";
position: absolute;
width: 0;
height: 0;
border-top: 15px solid transparent;
border-left: 10px solid #767676;
border-bottom: 15px solid transparent;
margin: -10px 0px 0px 10px;
z-index: 3;
}
li.testStatus:last-child:before, li.testStatusGood:before, li.testStatusNoGood:before {
content: "";
position: absolute;
width: 0;
height: 0;
left: 0;
border-top: 15px solid transparent;
border-left: 10px solid #EEEEEE;
border-bottom: 15px solid transparent;
margin: -10px 0px 0px 0px;
z-index: 2;
}
li.testStatus:first-child {
padding-left: 10px;
margin-left: 0;
background-color: #767676;
}
li.testStatus:last-child {
padding-right: 10px;
background-color: #767676;
}
li.testStatusGood {
background-color: #77a942;
}
li.testStatusGood:after {
border-left: 10px solid #77a942;
}
li.testStatusNoGood {
background-color: #c42c00;
}
li.testStatusNoGood:after {
border-left: 10px solid #c42c00;
}
/* End arrow formatting */
</style>
html
<ul>
<li>
<div id="testStatus">
<ul class="testStatus">
<li class="testStatus">Step 1</li>
<li class="testStatusGood">Step 2</li>
<li class="testStatusNoGood">Step 3</li>
<li class="testStatusNoGood">Step 4</li>
<li class="testStatus">Step 5</li>
</ul>
</div>
</li>
</ul>
My arrows display nicely but I am having difficulty adjusting the padding to 0. I've tried the #, the ul class, the il class and I am a bit baffled why I cannot remove the 10px (I believe its the padding).
There is also a faintly darker border on the left side of the triangular portion of the arrows, if you look closely, that I'd like to have match the color exactly.
Duo's code output above image, Ojer code output below image
I'm going backwards :)
Here you go:
.breadcrumbs {
border: 1px solid #cbd2d9;
border-radius: 0.3rem;
display: inline-flex;
overflow: hidden;
}
.breadcrumbs__item {
background: #fff;
color: #333;
outline: none;
padding: 0.75em 0.75em 0.75em 1.25em;
position: relative;
text-decoration: none;
transition: background 0.2s linear;
}
.breadcrumbs__item:hover:after,
.breadcrumbs__item:hover {
background: #edf1f5;
}
.breadcrumbs__item:focus:after,
.breadcrumbs__item:focus,
.breadcrumbs__item.is-active:focus {
background: #323f4a;
color: #fff;
}
.breadcrumbs__item:after,
.breadcrumbs__item:before {
background: white;
bottom: 0;
clip-path: polygon(50% 50%, -50% -50%, 0 100%);
content: "";
left: 100%;
position: absolute;
top: 0;
transition: background 0.2s linear;
width: 1em;
z-index: 1;
}
.breadcrumbs__item:before {
background: #cbd2d9;
margin-left: 1px;
}
.breadcrumbs__item:last-child {
border-right: none;
}
.breadcrumbs__item.is-active {
background: #edf1f5;
}
/* Some styles to make the page look a little nicer */
body {
color: #323f4a;
background: #f5f7fa;
display: flex;
align-items: center;
justify-content: center;
}
html, body {
height: 100%;
}
.gray{
background-color:gray;
}
.breadcrumbs__item.gray:after{
background-color:gray;
}
.red{
background-color:red;
}
.breadcrumbs__item.red:after{
background-color:red;
}
.green{
background-color:green;
}
.breadcrumbs__item.green:after{
background-color:green;
}
<li class="breadcrumbs">
Prospect
Opportunity
Accound
Sales
Support
</li>
This can work for you.
Check this Pen
HTML:
<ul class="steps">
<li class="past">
<span>
<strong>Step 1</strong>
</span><i></i>
</li>
<li class="present">
<span>
<strong>Step 2</strong>
</span><i></i>
</li>
<li class="future">
<span>
<strong>Step 3</strong>
</span><i></i>
</li>
<li class="future1">
<span>
<strong>Step 4</strong>
</span><i></i>
</li>
<li class="present1">
<span>
<strong>Step 5</strong>
</span><i></i>
</li>
</ul>
CSS:
.steps {
padding-left: 0;
list-style: none;
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
font-size: 12px;
line-height: 1;
margin: 30px auto;
border-radius: 3px;
}
.steps strong {
font-size: 14px;
display: block;
line-height: 2.1;
}
.steps > li {
position: relative;
display: block;
/* border: 1px solid #ddd; */
padding: 12px 50px 8px 50px;
width: 140px;
height: 40px;
}
#media (min-width: 768px) {
.steps > li {
float: left;
}
.steps .past {
color: #fff;
background: blue;
}
.steps .present {
color: #000;
background: yellow;
}
.steps .future {
color: #fff;
background: green;
}
.steps .present1 {
color: #000;
background: red;
}
.steps .future1 {
color: #fff;
background: purple;
}
.steps .present1 {
color: #fff;
}
.steps li > span:after,
.steps li > span:before {
content: "";
display: block;
width: 0px;
height: 0px;
position: absolute;
top: 0;
left: 0;
border: solid transparent;
border-left-color: #f0f0f0;
border-width: 30px;
}
.steps li > span:after {
top: -4px;
z-index: 1;
border-left-color: white;
border-width: 34px;
}
.steps li > span:before {
z-index: 2;
}
.steps li.past + li > span:before {
border-left-color: blue;
}
.steps li.present + li > span:before {
border-left-color: yellow;
}
.steps li.future + li > span:before {
border-left-color: green;
}
.steps li.future1 + li > span:before {
border-left-color: purple;
}
.steps li:first-child > span:after,
.steps li:first-child > span:before {
display: none;
}
/* Arrows at start and end */
.steps li:first-child i,
.steps li:last-child i {
display: block;
position: absolute;
top: 0;
left: 0;
border: solid transparent;
border-left-color: white;
border-width: 30px;
}
.steps li:last-child i {
left: auto;
right: -30px;
border-left-color: transparent;
border-top-color: white;
border-bottom-color: white;
}
}
I have been working on fixing this but cannot figure out what I am missing. I would like for drop down list to show right below its parent. The list shows but all go to far left and forces the remaining nav items to drop down to another line. i have included a snippet for what is currently looks like and an image of what I want it to look like. Also, I have been trying to figure out how to add down fa fa-caret to nav items with drop down list. Please help!
.navbar {
background: linear-gradient(#9E0A0C, #EBEBEB);
padding: 10px;
border-top: solid 1px #000000;
overflow: hidden;
}
.navbar a {
text-decoration: none;
color: #ffffff;
font-weight: bolder;
font-size: 20px;
text-transform: uppercase;
padding: 3px 5px;
margin: auto;
/*float: left; may need to be removed to show borders*/
display: inline;
}
.navbar ul {
padding: 0;
margin-top: 0;
width: auto;
}
.navbar li {
border-left: solid 2px #000000;
display: inline;
list-style-type: none;
width: 800px;
padding: 0;
}
.navbar a:active {
background-color: #000000;
}
.navbar a:hover {
background-color: #ddd;
color: black;
font-size: 20px;
}
li:first-child {
border-left: none;
}
.dropdown {
display: block;
overflow: hidden;
/*float: left;*/
}
.list {
display: none;
min-width: 50px;
max-width: 150px;
z-index: 2;
box-shadow: 0 8px 16px 0 #e7e7e7;
background: #050243;
}
.list a {
color: #000000;
float: none;
font-size: 14px;
text-decoration: none;
display: block;
text-align: left;
background: #B6B6B6;
columns: 2;
}
.list a:hover {
background-color: #EEEEEE;
}
.dropdown:hover .list {
display: block;
}
form {
float: right;
padding: 0px;
margin: 0;
overflow: auto;
}
input {
border: solid 1px #000000;
background-image: url(pics/search.png);
background-repeat: no-repeat;
background-position: center right;
background-size: 15px;
border-radius: 5px;
padding: 5px 2px;
width: 250px;
}
<div class="navbar">
<ul>
<li>Home</li>
<li class="dropdown">Our Lodge
<div class="list">
NEWS
FACILITIES
OFFICERS
GUEST BOOK
</div>
</li>
<li class="dropdown">Events
<div class="list">
CALENDAR
BINGO
</div>
</li>
<li class="dropdown">Contact Us
<div class="list">
BECOME AN ELK
</div>
</li>
<form action="#">
<input type="text" placeholder="Search.." name="search">
</form>
</ul>
</div>
You can achieve this by first making the div.list element into an absolute positioned. The 'display:block' property was pushing all the other content down to the next row because the block element was taking up space.
As you see now the list is no longer pushing the content down but now it is not aligned to the correct nav item. We are also going to add a left:0 so that the div.list is to the left of the parent property.
Now the parent property needs a position of relative so that the left:0 on the child element is being positioned relative to the parent element.
.dropdown:hover .list {
display: block;
position: absolute;
left: 0;
}
.navbar li {
border-left: solid 2px #000000;
display: inline;
list-style-type: none;
width: 800px;
padding: 0;
position: relative;
}
The problem with your CSS code is, you missed to add position: relative and position: absolute to the .dropdown and .list selectors, which is compulsory to create dropdown. Try this code.
.navbar {
background: linear-gradient(#9E0A0C, #EBEBEB);
padding: 10px;
border-top: solid 1px #000000;
}
.navbar a {
text-decoration: none;
color: #ffffff;
font-weight: bolder;
font-size: 20px;
text-transform: uppercase;
padding: 3px 5px;
margin: auto;
/*float: left; may need to be removed to show borders*/
display: inline;
}
.navbar ul {
padding: 0;
margin-top: 0;
width: auto;
}
.navbar li {
border-left: solid 2px #000000;
display: inline;
list-style-type: none;
width: 800px;
padding: 0;
}
.navbar a:active {
background-color: #000000;
}
.navbar li:hover > a {
background-color: #ddd;
color: black;
}
li:first-child {
border-left: none;
}
.dropdown {
display: block;
overflow: hidden;
position: relative;
/*float: left;*/
}
.list {
display: none;
min-width: 50px;
max-width: 150px;
z-index: 2;
box-shadow: 0 8px 16px 0 #e7e7e7;
background: #050243;
position: absolute;
left: 0;
top: 100%;
}
.list a {
color: #000000;
float: none;
font-size: 14px;
text-decoration: none;
display: block;
text-align: left;
background-color: #B6B6B6;
columns: 2;
}
.list a:hover {
background-color: #EEEEEE;
}
.dropdown:hover .list {
display: block;
}
form {
float: right;
padding: 0px;
margin: 0;
overflow: auto;
}
input {
border: solid 1px #000000;
background-image: url(pics/search.png);
background-repeat: no-repeat;
background-position: center right;
background-size: 15px;
border-radius: 5px;
padding: 5px 2px;
width: 250px;
}
--> Please update following code in your existing file
.navbar {
background: linear-gradient(#9E0A0C, #EBEBEB);
padding: 10px;
border-top: solid 1px #000000;
}
.navbar a {
text-decoration: none;
color: #ffffff;
font-weight: bolder;
font-size: 20px;
text-transform: uppercase;
padding: 3px 5px;
margin: auto;
display: inline;
}
.navbar ul {
padding: 0;
margin-top: 0;
width: auto;
}
.navbar li {
border-left: solid 2px #000000;
display: inline;
list-style-type: none;
width: 800px;
padding: 0;
position: relative;
}
.navbar a:active {
background-color: #000000;
}
.navbar a:hover {
background-color: #ddd;
color: black;
}
li:first-child {
border-left: none;
}
.dropdown {
display: block;
overflow: hidden;
}
.list {
opacity: 0;
visibility: hidden;
min-width: 50px;
max-width: 150px;
z-index: 2;
box-shadow: 0 8px 16px 0 #e7e7e7;
background: #050243;
position: absolute;
top: 20px;
left: 0;
transition: 0.3s ease-in-out;
}
.list a {
color: #000000;
float: none;
font-size: 14px;
text-decoration: none;
display: block;
text-align: left;
background: #dddddd;
columns: 2;
}
.list a:hover {
background-color: #EEEEEE;
}
.dropdown:hover .list {
opacity: 1;
visibility: visible;
}
form {
float: right;
padding: 0px;
margin: 0;
overflow: auto;
}
input {
border: solid 1px #000000;
background-image: url(pics/search.png);
background-repeat: no-repeat;
background-position: center right;
background-size: 15px;
border-radius: 5px;
padding: 5px 2px;
width: 250px;
}
<div class="navbar">
<ul>
<li>Home</li>
<li class="dropdown">Our Lodge
<div class="list">
NEWS
FACILITIES
OFFICERS
GUEST BOOK
</div>
</li>
<li class="dropdown">Events
<div class="list">
CALENDAR
BINGO
</div>
</li>
<li class="dropdown">Contact Us
<div class="list">
BECOME AN ELK
</div>
</li>
<form action="#">
<input type="text" placeholder="Search.." name="search">
</form>
</ul>
</div>
I would like to have a connecting vertical line between each circle. The "Sections" are dynamic in vertical height.
Here is the current SASS:
#import '../sass/sa.common';
$color: $sa-gray-4;
$colorActive: $sa-green;
$colorComplete: $sa-green;
.progress-indicator {
margin-bottom: 50px;
margin-top: 75px;
.step {
margin-top: 40px;
content: "";
display: table;
clear: both;
position: relative;
&:first-child {
margin-top: 0;
}
&:last-child {
div {
&.circle {
&:before {
display: none;
}
}
}
}
&.active {
div {
color: $colorActive;
&.circle {
border-color: $colorActive;
}
a {
color: $colorActive;
}
}
}
&.complete {
div {
color: $colorComplete;
&.circle {
border-color: $colorComplete;
&.filled {
background-color: $colorComplete;
color: $sa-white;
}
}
}
}
div {
color: $color;
display: table-cell;
float: left;
padding-top: 2px;
font-size: 16px;
font-weight: bold;
vertical-align: middle;
&.circle {
height: 30px;
width: 30px;
text-align: center;
border: 2px solid $color;
border-radius: 50%;
&:before {
content: "";
position: absolute;
z-index: 1;
margin-top: 26px;
left: 13px;
border: 1px solid $sa-gray-4;
height: 125%;
}
}
&.text {
padding-left: 10px;
padding-top: 5px;
ul {
margin: 0;
margin-top: 15px;
padding: 0;
list-style-type: none;
li {
a {
display: block;
margin-top: 5px;
&:first-child {
margin-top: 0;
}
}
}
}
}
}
}
}
CSS:
<style type="text/css">#charset "UTF-8";
.btn.btn-green {
background-color: #80b241;
color: #ffffff; }
.btn.btn-green:hover {
background-color: #88bc47; }
.btn.btn-gray-1 {
background-color: #595959;
color: #e7e5e1; }
.btn.btn-gray-1:hover {
background-color: #666666; }
.label.label-green {
background-color: #80b241;
color: #242424; }
.label.label-gray-1 {
background-color: #595959;
color: #ffffff; }
.btn.btn-green {
background-color: #80b241;
color: #ffffff; }
.btn.btn-green:hover {
background-color: #88bc47; }
.btn.btn-gray-1 {
background-color: #595959;
color: #e7e5e1; }
.btn.btn-gray-1:hover {
background-color: #666666; }
.label.label-green {
background-color: #80b241;
color: #242424; }
.label.label-gray-1 {
background-color: #595959;
color: #ffffff; }
.progress-indicator {
margin-bottom: 50px;
margin-top: 75px; }
.progress-indicator .step {
margin-top: 40px;
content: "";
display: table;
clear: both;
position: relative; }
.progress-indicator .step:before {
content: "";
position: absolute;
z-index: 1;
margin-top: 26px;
left: 13px;
border: 1px solid #ADABA6;
height: 125%; }
.progress-indicator .step:first-child {
margin-top: 0; }
.progress-indicator .step:last-child:before {
display: none; }
.progress-indicator .step.active div {
color: #80b241; }
.progress-indicator .step.active div.circle {
border-color: #80b241; }
.progress-indicator .step.active div a {
color: #80b241; }
.progress-indicator .step.complete div {
color: #80b241; }
.progress-indicator .step.complete div.circle {
border-color: #80b241; }
.progress-indicator .step.complete div.circle.filled {
background-color: #80b241;
color: #ffffff; }
.progress-indicator .step div {
color: #ADABA6;
display: table-cell;
float: left;
padding-top: 2px;
font-size: 16px;
font-weight: bold;
vertical-align: middle; }
.progress-indicator .step div.circle {
height: 30px;
width: 30px;
text-align: center;
border: 2px solid #ADABA6;
border-radius: 50%; }
.progress-indicator .step div.text {
padding-left: 10px;
padding-top: 5px; }
.progress-indicator .step div.text ul {
margin: 0;
margin-top: 15px;
padding: 0;
list-style-type: none; }
.progress-indicator .step div.text ul li a {
display: block;
margin-top: 5px; }
.progress-indicator .step div.text ul li a:first-child {
margin-top: 0; }
.category-selector {
margin-top: 30px; }
.category-selector .header {
border-bottom: 2px solid #80b241; }
.category-selector .header:before, .category-selector .header:after {
content: " ";
display: table; }
.category-selector .header:after {
clear: both; }
.category-selector .section-container:before, .category-selector .section-container:after {
content: " ";
display: table; }
.category-selector .section-container:after {
clear: both; }
.category-selector .section-container .section {
float: left;
height: 400px;
min-width: 150px;
overflow-y: scroll; }
.category-selector .section-container .section .item {
border-bottom: 1px solid #80b241;
cursor: pointer;
padding: 5px 10px 5px 5px; }
.category-selector .section-container .section .item:last-child {
border: 0; }
.category-selector .section-container .section .item.active {
background-color: #80b241;
color: #ffffff; }
</style>
And the Markup:
<div class="row">
<div class="col-lg-3">
<div class="progress-indicator">
<div class="step">
<div class="circle">1</div>
<div class="text">Select Category</div>
</div>
<div class="step active">
<div class="circle">2</div>
<div class="text">
Fill Out Listing
<ul>
<li>
Vital Fields
Image Url
Dimensions
</li>
</ul>
</div>
</div>
<div class="step">
<div class="circle">3</div>
<div class="text">Bulk Options</div>
</div>
<div class="step">
<div class="circle">4</div>
<div class="text">More Options</div>
</div>
</div>
<div class="text-center">
<button class="btn btn-default" style="margin-bottom: 10px;">
SAVE AS DRAFT
</button>
<button class="btn btn-gray-1">
MOVE TO PUBLISH QUEUE
</button>
</div>
</div>
<div class="col-lg-6">
<div class="category-selector">
<div class="header">
<div class="pull-left">
<h4>Select a Category</h4>
</div>
<div class="pull-right">
<button class="btn btn-green">Next</button>
</div>
</div>
<div class="section-container">
<div class="section">
<div class="item" [ngClass]="{active: selectedCategory && category.id === selectedCategory.id}" *ngFor="let category of topLevelCategories" (click)="getSubCategories(category)">
{{category.displayName}}
</div>
</div>
<div class="section" *ngIf="subCategories && subCategories.length > 0">
<div class="item" [ngClass]="{active: selectedSubCategory && subCategory.id === selectedSubCategory.id}" *ngFor="let subCategory of subCategories" (click)="getFields(subCategory)">
{{subCategory.displayName}}
</div>
</div>
</div>
</div>
</div>
<div class="col-lg-3">
Side Nav/Slide In
</div>
</div>
Not all browsers honor the display of ::before on elements with display:table. (I have a hunch you are experiencing this in FF? - In Chrome they're displayed). There are two possible fixes:
Either replace display:table with display:flex and display: table-cell with display: block...
...or use proper html elements (divs?) instead of pseudo-elements for lines.
Other notes you might find useful:
remove z-index from .step::before
change height:125% to height:calc(100% + {N}px) where {N} is the difference in px between the actual height of .circle and 40px (top margin of .step). Using this technique you can control exact size of line and match the gap between the circles down to the pixel, thus not needing to hide the extra line length.
Hope the above makes sense and helps. Don't forget to autoprefix.
Something like:
.step {
position: relative;
&:after {
content: "";
position: absolute;
top: 0;
left: 30px; // magic number, try until you get the right positioning
width: 1px;
height: 100%;
border-left: 2px solid $any-color-you-like;
}
}
Make some adjustments, and it should work as you need.
In some ways, I'm still pretty new to CSS and don't "get" how things are done (is seems convoluted, and there doesn't seem to be an easy way to figure things out) - so I am hoping someone here can help me. I'll post the relevant code. I am a programmer - but can't seem to figure out how to do what I want. (BTW - are there any good tools for 'visually' editing CSS? I'm doing this purely by code).
a) I need an HTML text box to expand/contract as the browser window expands/contracts, with a 'search' image icon to the right of it.
b) I need some signup/login buttons right justified
c) I need the logo/text left justified.
So basically the flow is:
[#1 logo] [#2 menu items ] [#3 search-bar with icon] [#4 login/signup buttons]
And if the browser window expands, then #3 expands to fill in the space.
i.e.,
small desktop
[#1][#2][#3][#4]
big desktop
[#1][#2][<#3-------------------------->][#4]
ideally, I'd also like to figure out on mobile (tiny desktop) how to make it:
[#1][#4]
[#3---->]
This is the HTML I have (with other stuff removed to make it simple)
/* General CSS */
* {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
body {
padding-top: 150px;
padding-bottom: 30px;
font-family: 'Open Sans', sans-serif;
font-size: 18px;
line-height: 1.42857143;
margin: 0;
}
ul {
list-style-type: none;
}
.clfix {
display: table;
content: " ";
clear: both;
}
.hide {
display: none;
}
/* Top bar */
.logo-separator {
float: left;
width: 1px;
border-right: 1px dashed #fff;
height: 80px;
padding-left:20px;
}
.navbar {
background-color: #124780;
position: fixed;
top: 0;
right: 0;
left: 0;
z-index: 1030;
}
.navbar .navbar-brand {
text-decoration: none;
float: left;
height: 85px;
padding: 15px 15px;
font-size: 18px;
line-height: 20px;
}
.navbar .navbar-header {
position: relative;
}
.navbar ul li a, .navbar .navbar-brand {
position: relative;
display: block;
padding: 15px;
line-height: 20px;
color: #fff;
text-decoration: none;
}
.nav.navbar-nav {
float: left;
margin: 50;
padding-left:20px;
color: #fff;
}
.navbar-nav > .separator {
padding: 15px 2px;
line-height: 20px;
}
.navbar-nav .dropdown .dropdown-menu > ul > li.separator {
padding: 5px 10px;
color: #000;
}
.navbar-nav .dropdown .dropdown-menu {
text-align:center;
display: none;
position: absolute;
background: #fff;
border-bottom: 1px solid #124780;
z-index: 999;
}
.navbar-nav .dropdown .dropdown-menu > li:hover > a {
background-color: #8fb4de;
}
.navbar-nav > li {
float: left;
}
/*
.nav.navbar-nav li > a:hover, .nav.navbar-nav > li.open a {
color: #000;
}*/
.top-buttons {
margin: 0;
padding: 0;
float:right;
}
.searchBar {
margin: 0;
padding: 0;
float:right;
border-style:solid;border-width:2px;border-color:#FF0000;
display:inline-flex;
background-color: #124780;
position: absolute;
top: 0;
right: 0;
left: 0;
}
.navbar-nav-button {
display: inline-block;
float:right;
padding-top:18px;
padding-right: 5px;
padding-left: 5px;
}
.top-buttons .btn.btn-sm {
padding: 5px 10px;
font-size: 12px;
line-height: 1.5;
border-radius: 7px;
display: inline-block;
margin-bottom: 0;
font-weight: 400;
text-align: center;
white-space: nowrap;
vertical-align: middle;
-ms-touch-action: manipulation;
touch-action: manipulation;
cursor: pointer;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
background-image: none;
border: 1px solid transparent;
width: 88px;
text-align: center;
}
.top-buttons .btn.btn-primary {
color: #fff;
background-color: #337ab7;
border-color: #2e6da4;
font-weight:bold;
}
.top-buttons .btn.btn-default {
color: #333;
background-color: #fff;
border-color: #ccc;
font-weight:bold;
}
.icon-bar {
background-color: #fff;
}
.navbar-nav2 {
display: inline-flex;
width: 100%;
padding-bottom: 5px;
padding-top: 0px;
position: absolute;
left: 0;
top: 85px;
background: #fff;
height: 35px;
overflow: hidden;
}
.navbar-line {
position: absolute;
bottom:0px;
width: 100%;
height: 1px;
background-color: #000;
left: 0;
}
/* Content */
.container {
padding-right: 15px;
padding-left: 15px;
margin-right: auto;
margin-left: auto;
}
.row {
margin-right: -15px;
margin-left: -15px;
}
.col-50 {
float: left;
width: 50%;
position: relative;
min-height: 1px;
padding-right: 15px;
padding-left: 15px;
}
/* Panels */
.submenu {
xborder: 1px solid #ebf2f2;
border-radius: 5px;
margin-bottom: 20px;
background-color: #fff;
}
.submenu .panel-heading {
background-color: #24a3d1;
border: 11px solid #ebf2f2;
cursor: pointer;
text-align: center;
border-radius: 25px;
padding: 20px 15px;
}
.submenu .panel-heading.expanded {
border: 11px solid #ebf2f2;
border-bottom-left-radius: 0;
border-bottom-right-radius: 0;
}
.submenu .panel-heading .fa-plus, .submenu .panel-heading.expanded .fa-minus {
display: block;
}
.submenu .panel-heading.expanded .fa-plus, .submenu .panel-heading .fa-minus {
display: none;
}
.submenu .panel-heading:hover {
background-color: #166988;
}
.submenu .panel-heading .panel-title {
display: inline-block;
margin: 0;
font-size: 20px;
color: #fff;
}
.submenu .panel-heading i.fa {
font-size: 25px;
color: #fff;
}
.submenu .panel-heading i:first-child {
float: left;
}
.submenu .panel-heading i.fa-plus, .submenu .panel-heading i.fa-minus {
float: right;
}
.submenu .panel-body {
padding: 0;
overflow: hidden;
}
.submenu .panel-body.closed {
display: none;
}
.submenu .panel-body ul {
border: 1px solid #ebf2f2;
border-bottom: 12px solid #ebf2f2;
margin: 0;
padding: 0;
}
.submenu .panel-body ul li a {
display: block;
padding: 12px 8px;
color: #000;
/* border-left: 1px solid #24a3d1;
border-right: 11px solid #ebf2f2; */
border-left: 11px solid #ebf2f2;
border-right: 11px solid #ebf2f2;
border-bottom: 1px solid #ebf2f2;
text-decoration: none;
font-size: 16px;
}
.submenu .panel-body ul li a i {
font-size: 12px;
color: #24a3d1;
}
.submenu .panel-body ul li a:hover, .submenu .panel-body ul li a:hover i {
color: #fff;
background-color: #24a3d1;
text-decoration: none;
}
/* Modals */
.modal {
position: fixed;
left: 0;
top: 0;
z-index: 2000;
width: 100%;
height: 100%;
}
.modal-overlay {
position: relative;
left: 0;
top: 0;
background-color: #000;
opacity: .7;
width: 100%;
height: 100%;
}
.modal-content {
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
padding-top: 60px;
padding-bottom: 60px;
padding-left: 20px;
padding-right: 20px;
}
.modal-body {
width: 100%;
background-color: #fff;
margin-left: auto;
margin-right: auto;
border-radius: 10px;
z-index:1000;
position:relative;
}
.modal-body .modal-row {
width: 100%;
}
.modal-body .close {
background: transparent;
border: 0;
float: right;
font-size: 20px;
color: #aeaeae;
cursor:pointer;
}
.modal-body .button-container {
width: 100%;
height: 30px;
padding: 5px 10px;
}
.modal .modal-title {
font-weight: 700;
text-align: center;
}
.modal .modal-subtitle {
text-align: center;
padding-top: 8px;
padding-bottom: 8px;
}
.modal-body .fields {
padding-top: 20px;
position: relative;
}
.modal-body .input-container {
display: block;
padding: 10px 30px;
font-size: 13px;
}
.modal-body .input {
display: block;
width: 100%;
height: 30px;
padding: 5px 10px;
font-size: 12px;
line-height: 1.5;
color: #555;
background-color: #fff;
background-image: none;
border: 1px solid #ccc;
border-radius: 3px;
-webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,.075);
box-shadow: inset 0 1px 1px rgba(0,0,0,.075);
-webkit-transition: border-color ease-in-out .15s,-webkit-box-shadow ease-in-out .15s;
-o-transition: border-color ease-in-out .15s,box-shadow ease-in-out .15s;
transition: border-color ease-in-out .15s,box-shadow ease-in-out .15s;
}
.modal-body .button {
padding: 8px 12px;
font-size: 12px;
line-height: 1.5;
border-radius: 3px;
display: inline-block;
margin-bottom: 0;
font-weight: 400;
text-align: center;
white-space: nowrap;
vertical-align: middle;
-ms-touch-action: manipulation;
touch-action: manipulation;
cursor: pointer;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
background-image: none;
border: 1px solid transparent;
width: 100%;
}
.modal-body a.forgot {
float: right;
}
.modal-body .button.btn-primary {
color: #fff;
background-color: #337ab7;
border-color: #2e6da4;
}
.modal-body .button.facebook {
background-color: #3b5998;
color: #fff
}
.modal-body .button.google-plus {
background-color: #d9534f;
color: #fff
}
.modal-body .not-member {
text-align: center;
padding-top: 30px;
}
.modal-body .horizontal-line {
padding-top: 15px;
border-bottom: 2px solid #dedede;
}
.modal-body .bottom-message {
padding: 20px;
text-align: center;
font-size: 13px;
}
.modal-body .bottom-message {
background-color: #f8f8f8;
}
.modal-body .grey {
color: #a19997;
}
.navbar-nav .dropdown-menu > li > a {
color: #fff;
background-color: #4692e6;
text-align:left;
padding: 10px 30px;
border-bottom: 1px solid #fff;
}
.navbar-nav2 a {
text-decoration: none;
text-transform: uppercase;
font-size: 12px;
font-weight: bold;
top:220px;
}
.navbar-nav2 .custom {
text-decoration: none;
text-transform: uppercase;
font-size: 12px;
top:220px;
}
#media (min-width: 768px) {
.container, .modal-body {
width: 750px;
}
.top-buttons {
position: absolute;
top: 10px;
/* i took this out because it was screwing things up display: inline-flex; */
display: inline-flex;
}
.navbar-toggle {
display: none;
}
.navbar-nav > li:hover > a, .navbar-nav > li.active > a {
color: #aeaeae;
}
.navbar-nav > .dropdown {
position: relative;
}
.navbar-nav > .dropdown > .fa-caret-up {
position: absolute;
bottom: -4px;
left: 50%;
transform: translateX(-50%);
color:#4692e6;
display: none;
}
.navbar-nav .dropdown-menu > li > a {
width: 250px;
}
.navbar-nav > li:hover .dropdown-menu, .navbar-nav > li:hover > .fa-caret-up {
display: block;
padding:0;
}
.modal-body .vertical-line {
position: absolute;
height: 100%;
left: 50%;
transform: translateX(-50%);
}
.modal-body .vertical-line .line-color {
width: 1px;
background-color: #eee;
height: 87%;
position: absolute;
left: 50%;
}
.modal-body .vertical-line .vertical-message{
display: block;
margin-top: 75px;
background-color: #fff;
color: #696463;
position: relative;
}
}
#media (min-width: 992px) {
.container {
width: 970px;
}
}
#media (min-width: 1200px) {
.container {
width: 1170px;
}
}
#media ( max-width: 767px) {
body {
padding-top: 110px;
}
.navbar {
background-color: #124780;
position: absolute;
}
.separator {
display: none;
}
.modal-body .vertical-line {
display: block;
width: 100%;
float: left;
padding: 10px;
position: relative;
text-align: center;
}
.modal-body .vertical-line .line-color {
position: absolute;
width: 90%;
background-color: #eee;
top: 50%;
height: 1px;
left: 5%;
}
.modal-body .vertical-line .vertical-message{
background-color: #fff;
color: #696463;
position: relative;
}
.logo-separator {
display: none;
}
.navbar {
max-height: 340px;
}
.navbar-nav, .navbar-nav .dropdown-menu, .navbar-nav2 {
display: none;
}
.navbar-nav.open, .navbar-nav .dropdown-menu.open, .navbar-nav2.open {
display: block;
}
.navbar .container {
width: 100%;
padding: 0;
margin: 0;
}
.navbar .container .navbar-header{
position: relative;
width: 100%;
}
.navbar-toggle {
position: relative;
float: right;
padding: 9px 10px;
margin-top: 8px;
margin-right: 15px;
margin-bottom: 8px;
background-color: transparent;
background-image: none;
border: 1px solid transparent;
border-radius: 4px;
cursor: pointer;
}
.navbar-toggle .icon-bar {
display: block;
width: 22px;
height: 2px;
border-radius: 1px;
background-color: #fff;
}
.navbar-nav > .dropdown > .fa-caret-up {
display: none;
}
.navbar-header:before, .navbar-header:after{
content: " ";
}
.navbar-toggle .icon-bar+.icon-bar {
margin-top: 4px;
}
.navbar .navbar-nav, .navbar .navbar-nav .dropdown-menu > ul {
margin: 0;
padding: 0;
width: 100%;
}
.navbar .navbar-nav >li>a {
background-color: #78b1eb;
}
.navbar .navbar-nav >li:hover>a {
background-color: #a6c6e6;
}
.navbar .navbar-nav >li>.dropdown-menu {
margin-bottom:0;
margin-top:0;
padding-bottom: 0;
padding-top: 0;
position: relative;
padding-left:0;
}
.navbar .navbar-nav >li>.dropdown-menu>ul>li>a {
color: #fff;
background-color: #aacef2;
text-align:left;
padding: 10px 30px;
border-bottom: 1px solid #fff;
}
.navbar .navbar-nav2 {
padding-top: 0;
position: relative;
top: 0;
height: auto;
}
.navbar .navbar-nav2 a {
display: block;
padding: 10px 15px;
border-bottom: 1px solid #aaa;
}
.navbar .navbar-nav2 a:hover {
background-color: #fff1f1;
color: #5d5aff;
}
.navbar .navbar-nav2 span.separator {
display: none;
}
.navbar ul li {
float: none;
}
.top-buttons {
position: absolute;
top: 10px;
right: 60px;
}
.col-50 {
width: 100%;
}
}
<nav class="navbar">
<div class="container clfix">
<div class="navbar-header">
<button type="button" class="navbar-toggle">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#"><img src=./mylogo.jpg><img src=./mytextlogo.gif></a>
<div class="logo-separator"></div>
</div>
<div id="navbar">
<ul class="nav navbar-nav">
<li class="dropdown">
Menu Item 1
</li>
<li class="separator">|</li>
<li class="dropdown">
Menu Item 1
</li>
<li class="separator">|</li>
<li class="dropdown">
Menu Item 3
</li>
<li class="separator">|</li>
</ul>
<div class="navbar-nav2">
<div class="navbar-line"></div>
<div class="container" style="width:100%" align=center>
Secondary Menu 1
Secondary Menu 2
</div>
</div>
</div><!--/.nav-collapse -->
//--------------------------------------------------------------------------------------------
/* THIS IS WHERE I WANT A SEARCH BAR WITH ICON TO EXPAND/CONTRACT BASED ON BROWSER WIDTH
//--------------------------------------------------------------------------------------------
<div class=searchBar>
<input name=something type=text width=40><img src=./searchbutton.jpg>
</div>
//--------------------------------------------------------------------------------------------
/* I WANT THESE BUTTONS 'RIGHT' JUSTIFIED HERE
//--------------------------------------------------------------------------------------------
<div >
<ul class="top-buttons" style="width:100%;border-style:solid;border-width:2px;border-color:#FF0000;float:right">
<li class="navbar-nav-button"><Button id="btn-login" class="btn btn-primary btn-sm">Log in</Button></li>
<li class="navbar-nav-button"><Button id="btn-signup" class="btn btn-default btn-sm">Sign Up</Button></li>
</ul>
</div>
</div>
</nav>
any help would be greatly appreciated!
Sounds like you will need judicious use of media queries:
#media screen and (min-width: 480px) {
body {
background-color: lightgreen;
}
}
http://www.w3schools.com/cssref/css3_pr_mediaquery.asp
You've already indicated the three device sizes you need media queries for:
small desktop
[#1][#2][#3][#4]
big desktop
[#1][#2][<#3-------------------------->][#4]
mobile
[#1][#4]
[#3---->]
Now you just need to create media queries for those three sizes and set the CSS accordingly.
Mobile: Hide #2. Maybe play with floats to get #3 to display below the other two.
Big Desktop: Change #3 width (percentage based most likely)
Small Desktop: #1, #2, #3, #4 should all have the same width (percentage based most likely)
You can then use the width property to adjust the size of buttons on these different media widths:
http://www.w3schools.com/cssref/pr_dim_width.asp
So I'm working on a CSS drop down menu where the div container is revealed by a radio button and I have that working as I'd like.
However, I'd like to add a second level to my drop-down just like it (same width, positioning beneath parent, ect..) I have it revealing the second level when you click on the input, however, If the input is in the middle (in between two links) my first level's links move beneath my first level of sub-menu. Please help? I can't figure out how to keep it looking the same way it's just if that input has another sub menu I would like for it to drop down below the first.
My code:
/*CSS for Menu */
.menu {
position: fixed;
top: 0;
left: 0;
height: 20px;
width: 100%;
z-index: 10000;
display: inline-block;
background-image: black url(../images/glossyback.gif);
background-color: #0066CC;
text-align: center;
font-family: Arial, Geneva, sans-serif;
}
/*CSS for main menu labels */
input + label {
color: #FFFFFF;
display: inline-block;
padding: 6px 8px 10px 24px;
background-image: black url(../images/glossyback2.gif);
height: 8px;
margin: 0;
line-height: 12px;
position: relative;
}
input:hover + label:hover {
background: #3385D6;
}
input + label + div {
margin: 0;
margin-top: 2px;
padding: 16px;
border: 1px solid;
width: 100%;
height: auto;
position: absolute;
top: 20px;
display: none;
}
input:checked + label + div {
display: block;
}
/*CSS for main menu labels within menu class*/
.menu input {
display: none;
opacity: .3;
margin-right: -.7em;
margin-left: 0em;
overflow: visible;
}
.menu a {
text-decoration: none;
color: #FFFFFF;
}
.menu label span {
z-index: 1000;
font-size: 12px;
line-height: 9px;
padding: 6px 1em 12px 1em;
display: block;
margin-top: -1px;
background-image: url(../images/glossyback.gif) repeat-x bottom left;
}
.menu label span a:hover {
background-image: black url(../images/glossyback2.gif);
}
.menu input:checked + label {
background-color: #AFCEEE;
border-color: #6696CB;
z-index: 1000;
}
div.menu input + label {
z-index: 1000;
padding: 0;
border-color: #ccc;
border-width: 0 1px;
height: 19px;
margin: 0 -.23em;
}
/*CSS for submenu container */
.menu input + label + div {
position: absolute;
border: 1px solid #808080;
right: 0;
background: #F0F6FC;
text-align: center;
width: 100%;
margin: 0 auto;
}
.menu input + label + div > div {
z-index: 1000;
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
border: 1px solid #ABABAB;
padding: 16px;
padding-top: 5px;
}
/*CSS for sub menu items*/
.sub-menu {
font-size: 14px;
display: inline-block;
}
.sub-menu a {
text-decoration: none;
color: #EEEEEE;
}
.sub-menu ul {
list-style-type: none;
}
.sub-menu li {
width: 175px;
color: #F0F0F0;
background-color: #9CB9D7;
display: inline-block;
}
.sub-menu li:hover {
color: #FFFFFF;
text-decoration: none;
background-color: #3385D6;
}
/*CSS for sub-menu second level */
.sub-menu input[type=radio] {
display: none;
}
.sub-menu input[type=radio]:checked ~ .remove-check {
display: none;
}
.sub-menu input[type=radio]:checked ~ #second-level {
display: block;
}
#second-level {
display: none;
}
/* The styling of items, ect...*/
.sub-menu input[type=text] {
width: 225px;
padding: 12px 14px;
}
.sub-menu div {
border: 1px solid #808080;
right: 0;
background: #F0F6FC;
text-align: center;
width: 100%;
margin: 0 auto;
}
.sub-menu div div {
top: 90%;
z-index: 1000;
position: absolute;
border: 1px solid #ABABAB;
padding: 16px;
padding-top: 5px;
}
.sub-menu .second-level-items {
width: 175px;
color: #F0F0F0;
background-color: #9CB9D7;
display: inline-block;
}
<div class="menu">
<input type="radio" name="UItab" id="tabf">
<label for="tabf"><span>Styles</span>
</label>
<div>
<div>
<ul class="sub-menu">
<a href="">
<li id="linkj">First Link</li>
</a>
<label for="reveal-email">
<li>Tab in submenu</li>
</label>
<input type="radio" id="reveal-email">
<div id="second-level">
<div>
<a href="">
<li>Links2.0</li>
</a>
</div>
</div>
<label for="reveal-email">
<li>Tab in submenu</li>
</label>
<input type="radio" id="reveal-email">
<div id="second-level">
<div>
<a class="second-level-items" href="">
<li>Links2.0</li>
</a>
</div>
</div>
<a href="">
<li id="linkj">First Link</li>
</a>
</div>
</div>
</div>