how to stop js created borders to effect other elements? - css

There is a horizontal menu in my website and items inside it have no border. but I want it to have 1px border on mouseover, so when I move the mouse on it, this newly created border moves other elements to the left, about 2px (because border-right = border-left = 1px).
this is my code
<div id="library_category_wrapper">
<ul>
<li>Item1</li>
<li>Item1</li>
<li>Item1</li>
<li>Item1</li>
</ul>
</div>
and this is css
#library_category_wrapper ul
{
list-style: none;
float: right;
position: relative;
top:5px;
margin: auto;
}
#library_category_wrapper ul li
{
display: inline;
margin-left:8px;
padding : 4px;
}
#library_category_wrapper li:hover
{
background: none repeat scroll 0 0 rgba(0, 0, 0, 0);
border : 1px solid rgba(0, 0, 0, 0.25);
border-radius : 4px 4px 4px 4px;
box-shadow : 0 0 5px rgba(0, 0, 0, 0.4) inset, 0 1px 0 rgba(255, 255, 255, 0.1);
text-shadow : 0 -1px 0 rgba(0, 0, 0, 0.796), 0 0 10px rgba(255, 255, 255, 0.298);
padding : 4px;
}
this is DEMO

You can simply put a transparent border on the normal state like this: http://jsfiddle.net/Pn8uw/1/
#library_category_wrapper ul li {
border : 1px solid rgba(0, 0, 0, 0);
}

You could add a 'transparent' border to the default LI state:
#library_category_wrapper ul li {
border: 1px solid transparent;
}
Demo: http://jsfiddle.net/Pn8uw/2/

You can simply reduce the padding on hover. Add the following property instead of your padding: 4px;
#library_category_wrapper li:hover {
padding: 3px;
}
fiddle

Related

CSS issues with NavBar

I am having a couple issues with my Navigation bar. The first issue is I cannot figure out how to make the "active" size the same size as my hover. You will notice that the entire height of the navigation bar is highlighted on active.
Secondly, for some reason it isn't as apparent on codepen but in my actual situation my "main" div is on the same plane as the navbar resulting in the drop shadow to not be even and crisp. Hopefully you can see what I mean from the following image. I have tried playing with z-index with no luck.
https://codepen.io/kjpolker/pen/RMqNbL
Image is of the navigation bar itnersecting with the main div. The shadow almost "fades" out on the edge, how can I put the shadow in front?
HTML
<body>
<nav class="navigation-bar">
<img class="logo" src="images/logo.png" alt="Logo" width="100" height="100"/>
<ul>
<li class="active">TAB 1</li>
<li>TAB 2</li>
<li>TAB 3</li>
<li>TAB 4</li>
<li>TAB 5</li>
</ul>
</nav>
<main class="main">
<article class="summary">
<p></p>
</article>
<article id="image">
<img src="images/map.png" alt="" width="80%" height="80%" />
</article>
</main>
</body>
CSS
* {margin:0;padding:0;box-sizing:border-box}
html, body {text-align: center;}
body {
background-image: url(../images/BG.jpg); background-size: 100% 100%; background-position: top left; background-repeat: repeat;
justify-content: center; /* horizontal alignment / centering */
align-items: flex-start; /* prevents the #menu to fill the remaining height of the body */
}
.navigation-bar {
opacity: .9;
text-align: center;
width: 100%;
height: 120px;
background: #2A2A2A;
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.7), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
/*
-webkit-box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
-moz-box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
*/
}
.logo {
float: left;
margin-left: 5%;
margin-right: 5%;
margin-top: 10px;
}
/* used with 100% wrapper */
ul {
display: inline;
display: flex; /* displays children inline */
width: 60%;
height: 120px;
list-style: none;
background: #2A2A2A;
}
li {
flex: 1; /* each takes as much width as it can, i.e. 25% */
}
li:last-child {
border-left: none;
border-right: none;
}
li a {
margin-top: 30px;
display: block;
text-align: center;
font: Verdana;
font-size: 16px;
color: #EAEAEA;
text-decoration: none;
padding: 20px 0; /* This adjusts the height of the tabs */
}
li a:hover {
background: linear-gradient(#404040, #3E3E3E);
}
.active {
background: linear-gradient(#2B2B2B, #232323);
}
p {
font-family: Verdana;
font-size: 16px;
}
/* Used in Home */
.main {
opacity: .75;
color: #EAE0D2;
margin: 0 auto;
width: 85%;
height: 1000px;
margin-top: 0;
background: linear-gradient(#2B2B2B, #232323);
box-shadow: 0 2px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
-webkit-box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
-moz-box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
}
If my understanding is correct, For your first issue changing
.active {
background: linear-gradient(#2B2B2B, #232323);
}
to
.active a{
background: linear-gradient(#2B2B2B, #232323);
}
will solve the issue.

Remove Box Shadow from Left Side

I'm creating a custom sider toggle for an ant design project and I'm struggling to preserve three sides (i.e top, right, left) of the box-shadow (i.e. 2px 2px 8px rgba(0, 0, 0, 0.15)) and remove the box-shadow/blur entirely from the left side. My most recent attempt is below. Any thoughts?
JSX:
<span onClick={this.toggleCollapse} className="ant-layout-sider-zero-width-trigger">
{collapsed ? <Icon type="menu-unfold" /> : <Icon type="menu-fold" />}
</span>
LESS:
.ant-layout-sider-zero-width-trigger {
background: #fff;
color: #000000a6;
box-shadow: 2px 2px 8px rgba(0, 0, 0, 0.15), inset -2px 0px 0px #fff;
&:hover {
background: #fff;
}
}
btw I've seen similar questions on Stack but none worked for me after much experimentation.
An idea is to use another container and rely on some overflow:
.container {
display:inline-block;
padding:5px 5px 5px 0;
overflow:hidden;
}
.box {
width:200px;
height:50px;
background: #fff;
color: #000000a6;
box-shadow:
2px 2px 8px rgba(0, 0, 0, 0.15),
inset -2px 0px 0px #fff;
}
<div class="container">
<div class="box">
</div>
</div>
You could increase the offset of the shadow and reduce its size:
html {
background: white;
}
body {
padding: 2em;
margin: 2em;
background: yellow;
box-shadow: 4px 4px 8px -4px, inset -2px 0px 0px #fff;
}

Some Css style sheet selectors ONLY taking effect on Firefox on my responsive theme

I have a responsive theme installed, I have used FireBug from fire fox to change the colors of certain parts of my website, and everything works perfectly on Firefox. BUT the second I look on Google chrome, Internet Explorer, and my Phone it ALL looks horribly off. Mostly it's the header widget tags as they are supposed to NOT be red.
This I think is whats not taking affect (it's the backgrounds not taking affect)? :
#secondary .widget_fearless_tabs .headings a {
background: linear-gradient(to bottom, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0)) repeat scroll 0 0 #333333 !important;
border-left: 1px solid rgba(255, 255, 255, 0.15) !important;
border-right: 1px solid rgba(0, 0, 0, 0.5) !important;
color: #CCCCCC !important;
display: block !important;
font-size: 1.3rem !important;
margin: 0;
outline: 0 none;
padding: 0.9em 0;
text-align: center;
}
button:hover, .flexslider .category-label, .layout-module .widget-title > span, .pagination a:hover, .pagination .current, #primary-navigation .menu li.current-menu-item, #primary-navigation .menu li.current-menu-ancestor, #primary-navigation .menu li.current_page_item, #primary-navigation .menu > li:hover, #primary-navigation .menu > li.sfHover, #primary-navigation .menu ul a:hover, #primary-navigation .menu ul li.current-menu-item a, .review-box .heading, #searchform #searchsubmit:hover, #secondary .widget_fearless_tabs .headings a.active, section.top-reviews .review-column-1 h2, .sidebar-primary .widget-title, .wpcf7-submit:hover {
background: -moz-linear-gradient(center top, #FEFEFE, #F4F4F4) repeat scroll 0 0 padding-box rgba(0, 0, 0, 0) !important;
border: 1px solid #E0E0E0 !important;
border-radius: 1px !important;
box-shadow: 0 1px 0 0 rgba(255, 255, 255, 0.9) inset !important;
color: #182945 !important;
}
/* This changes colors of hover secondary widget headings like review widget */
#secondary .widget_fearless_tabs .headings a:hover {
background: -moz-linear-gradient(center top, #FFFFFF, #F6F6F6) repeat scroll 0 0 padding-box rgba(0, 0, 0, 0) !important;
border: 1px solid #E0E0E0 !important;
border-radius: 1px !important;
box-shadow: 0 1px 0 0 rgba(255, 255, 255, 0.9) inset !important;
color: #40516D !important;
}
I don’t understand why this is not working? I have also looked at the original style sheet of my theme and can't find any thing to point me in the right direction to add to my child theme?
-moz surprisingly works just in mozilla. If you include the gradient for every other browser it will work in every other browser.
I always use http://www.colorzilla.com/gradient-editor/ to create the code so I don't forget something.
Add liner gradient for all other browsers too
#secondary .widget_fearless_tabs .headings a:hover {
background: -moz-linear-gradient(center top , #FFFFFF, #F6F6F6) repeat scroll 0 0 padding-box rgba(0, 0, 0, 0) !important;
//for all other browsers
background: -o-linear-gradient(center top , #FFFFFF, #F6F6F6) repeat scroll 0 0 padding-box rgba(0, 0, 0, 0) !important;
border: 1px solid #E0E0E0 !important;
border-radius: 1px !important;
box-shadow: 0 1px 0 0 rgba(255, 255, 255, 0.9) inset !important;
color: #40516D !important;
}

How to override bootstrap responsive nav-btn

Hi I am trying to override the css for the bootstrap nav btn in my css, I want to change the colour and thickness of the 3 white lins but I have had trouble finding where to change I know it is to do with the span icon-bar but not sure where in the css.
Try this...
.navbar-inverse .navbar-toggle .icon-bar {
width: 20px;
height: 4px;
background-color: #cc0000;
display: block;
}
Demo: http://bootply.com/79822
The class you are looking for is "icon-bar"
This controls the bars.
Look for the below code in the css file:
.navbar .btn-navbar .icon-bar {
display: block;
width: 18px;
height: 2px;
background-color: #f5f5f5;
-webkit-border-radius: 1px;
-moz-border-radius: 1px;
border-radius: 1px;
-webkit-box-shadow: 0 1px 0 rgba(0, 0, 0, 0.25);
-moz-box-shadow: 0 1px 0 rgba(0, 0, 0, 0.25);
box-shadow: 0 1px 0 rgba(0, 0, 0, 0.25);
}
Modify this as you see fit.
Good luck!

Bootstrap dropdown content to the right of link

I am making a bootstrap mega menu in which the navigation was originally meant to be floating left. I have changed it to float right using the pull-right class provided by Bootstrap but now all my dropdowns are still appearing as if the nav was still floating left. How can I adjust the dropdown content to reflect the floating change?
Attached is an image of my problem:
As you can see the dropdown caret arrow pointing at Merchandising is off a little bit, which I can adjust. But the content of the dropdown should be to the right of the nav item, not the left. All bootstrap styles are default, except for the following CSS:
.dropdown-menu {
position: absolute;
top: 100%;
left: -1px;
z-index: 1000;
display: none;
float: left;
min-width: 160px;
padding: 10px 10px;
margin: 0px 0 0;
list-style: none;
background-color: #fff;
border-top: transparent;
border-left: 1px solid rgba(0, 0, 0, .1);
border-right: 1px solid rgba(0, 0, 0, .1);
border-bottom: 1px solid rgba(0, 0, 0, .1);
-webkit-border-radius: 0;
-moz-border-radius: 0;
border-radius: 0;
-webkit-box-shadow: 0 0px 0px rgba(0, 0, 0, 0.2);
-moz-box-shadow: 0 0px 0px rgba(0,0,0,0.2);
box-shadow: 0 0px 0px rgba(0, 0, 0, 0.2);
-webkit-background-clip: padding-box;
-moz-background-clip: padding;
background-clip: padding-box;
}

Resources