Is it possible to disable all global CSS inside a VueJS component in order to allow only scoped CSS in the component ? If yes, how ?
The problem I'm trying to solve is detailed below.
* {
margin: 0 auto;
padding: 0;
text-align: center;
color: black;
font-family: tahoma;
}
.items ul {
padding-top: 20px;
position: relative;
}
/* Make all children "inline" */
.items li {
/*float: left;*/
display: inline-block;
text-align: center;
list-style-type: none;
position: relative;
padding: 20px 5px 0 5px;
}
/* Add horizontal connector. Note: they are 2 pseudo-elements */
.items li::before, .items li::after {
content: '';
position: absolute;
top: 0;
right: 50%;
width: 55%;
height: 42px;
z-index: -1;
border-top: 1px solid #CCC;
}
.items li::after {
border-left: 1px solid #CCC;
left: 50%;
right: auto;
}
/* Remove left and right connector from a single child */
.items li:only-child::after, .items li:only-child::before {
display: none;
}
.items li:only-child {
padding-top: 0;
}
/* Remove "outer" connector */
.items li:first-child::before, .items li:last-child::after {
border: 0 none;
}
/* Add back the down connector for last node */
.items li:last-child::before {
border-right: 1px solid #CCC;
border-radius: 0 5px 0 0;
}
/* Add curve line to the first child's connector */
.items li:first-child::after {
border-radius: 5px 0 0 0;
}
/* Add down connector from parent */
.items ul ul::before {
content: '';
border-left: 1px solid #CCC;
z-index: -1;
height: 20px;
position: absolute;
top: 0px;
left: 50%;
width: 0;
}
/* Add cosmetic for each item */
.items li a {
font-size: 12px;
background-color: white;
border: 1px solid #CCC;
padding: 5px 10px;
height: 14px;
text-decoration: none;
display: inline-block;
border-radius: 4px;
}
/* Change bg-color while hovering each item */
.items li a:hover {
background-color: #EEF;
}
/* EXPERIMENTAL for multiple parents */
/* Add margin for the parents */
.items li a:not(:only-of-type) {
position: relative;
margin-bottom: 16px;
}
/* Add "down" connector (vertical line) from each multi-parent, EXCEPT the last one */
.items li > a:not(:last-of-type)::after{
content: '';
position: absolute;
border-left: 1px solid #CCC;
border-bottom: 1px solid #CCC;
top: 20px;
width: 75%;
height: 20px;
left: 50%;
z-index: -1;
}
/* Special case for the last multiple-parent, using border-right */
.items li > a:not(:only-of-type):last-of-type::after {
content: '';
position: absolute;
border-right: 1px solid #CCC;
border-bottom: 1px solid #CCC;
top: 20px;
width: 50%;
height: 20px;
right: 50%;
z-index: -1;
border-bottom-right-radius: 5px;
}
/* Give the curve line to the first multiple parent .... */
.items li > a:not(:only-of-type):first-child::after {
border-bottom-left-radius: 5px;
}
/* The middle element of multi-parents*/
.items li > a:not(:first-child):not(:last-of-type)::before {
content: '';
position: absolute;
border-bottom: 1px solid #CCC;
top: 40px;
width: 50%;
right: 50%;
z-index: -1;
}
.items ul:last-of-type li {
padding-left: 0;
padding-right: 0;
}
<div class="items">
<ul>
<li>
Dagon
Veil of Discord
Other Parent Item
<ul>
<li>
Null Talisman
<ul>
<li>Circlet</li>
<li>Mantle of Intelligence</li>
<li>Recipe: Null Talisman</li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
This code comes from https://jsfiddle.net/sangprabo/o8dda3um/23/
But I get some css perturbation coming from Laravel global CSS, like shown in the image below, this is why I'd like to disable any CSS causing these perturbation.
I finally fixed it by adding this in my component's CSS:
<style lang="css" scoped>
*, *::before, *::after {
box-sizing: content-box;
}
...
</style>
Related
I'm using a trick to add a border between navigation items
li {
&:not(.active) {
&::before {
border-bottom: grey;
bottom: 0;
content: '';
height: 1px;
left: 20px;
position: absolute;
width: 220px;
:host-context(.minified) {
display: none;
}
}
It works fine. You can see the yellow marked line.
If navigation is active i do not add this border.
If the navigation link is active, i would like to remove the border from previous sibling. You can see the red arrow.
Anybody ideas how can i do that?
You can define the divider at the top of the li and remove the first divider with li:first-child:after
Now, when hovering you can access the next li with + and set the background to be transparent.
Here's an example:
html, body{
padding: 0px;
margin: 0px;
}
ul {
border-right: 2px solid #e5e5e5;
width: 180px;
box-shadow: 5px 2px 10px #e5e5e5;
margin: 0px;
padding: 0px;
}
li {
list-style-type: none;
height: 40px;
display: flex;
align-items: center;
margin: 0px;
padding-left: 15px;
position: relative;
}
li:after{
position: absolute;
background-color: #e5e5e5;
top: 1px;
height: 1px;
width: 130px;
left: 20px;
z-index: 1;
content: "";
}
li:first-child:after{
height: 0px;
}
li:hover {
color: #13A83E;
background-color: #e5e5e5;
}
li:hover + li:after {
background-color: transparent;
}
<ul>
<li>Dashboard</li>
<li>Assets</li>
<li>Devices</li>
<li>More</li>
<li>Options</li>
</ul>
I am trying to get the the menu on the right side of the search bar to breakout of the parent.
Code: http://jsbin.com/xecolubodi/edit?html,css,js,output
I believe a modified to the following css styles is required:
.mapsearch-menu ul {
display: none;
position: relative;
top: -55px;
padding: 55px 0 0 0;
margin: 0;
user-select: none;
}
.mapsearch-menu ul:hover {
display: block;
}
.mapsearch-menu li {
background: white;
padding: 4px;
list-style: none;
border: 1px solid rgba(0, 0, 0, 0.298039);
margin-top: -1px;
}
.mapsearch-menu input[type=checkbox],
input[type=radio] {
vertical-align: middle;
position: relative;
bottom: 1px;
}
.mapsearch-menu li:hover {
background: #eee;
cursor: pointer;
}
.mapsearch-menu .button {
display: inline-block;
user-select: none;
cursor: pointer;
height: 16px;
width: 16px;
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAJ0lEQVQ4y2NgGDbgJBD/JxGfQDbgOBkGHB1mYXBi6IfBmdEwIB8AAEQSURX+8q0jAAAAAElFTkSuQmCC");
}
.mapsearch-menu {
display: inline-block;
position: absolute;
top: 0;
right: 0;
margin-top: 12px;
padding-right: 5px;
}
Before click:
After click:
I want the hamburger menu icon to stay stationary and have the dropdown menu either breakout of the parent divs bounds or have the list items right justified.
I have been working on this for an hour and I am not getting anywhere. I tried various things (floating, etc).
ps: I prefer to have the search icon, the search text, and the hamburger all left-floated instead of the hack I am currently doing with padding with the search. If that is easier to fix that first then please attempt (I also been trying to fix that)
I updated your css below, It will probably work for you.
.mapsearch-menu ul {
display: none;
position: absolute; /* Add this you can change it as per you need */
top: -34px; /* Add this */
right:0px; /* Add this you can change it as per you need */
min-width:170px; /* Add this */
padding: 55px 0 0 0;
margin: 0;
user-select: none;
}
.mapsearch-menu .button {
display: inline-block;
user-select: none;
cursor: pointer;
position:relative; /* Add this */
height: 16px;
width: 16px;
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAJ0lEQVQ4y2NgGDbgJBD/JxGfQDbgOBkGHB1mYXBi6IfBmdEwIB8AAEQSURX+8q0jAAAAAElFTkSuQmCC");
}
.mapsearch-menu li {
background: white;
padding: 4px;
list-style: none;
border: 1px solid rgba(0, 0, 0, 0.298039);
margin-top: -1px;
display:inline-block; /* Add this */
}
nav.page-nav {
background-color: #1d1d1d;
line-height: 6rem;
font-size: 1.7rem;
}
nav.page-nav .container {
display: -ms-flexbox;
}
nav.page-nav a {
display: block;
width: 9rem;
padding: 0 1.8rem;
border-right: 1px dotted #3d3d3d;
text-decoration: none;
text-transform: uppercase;
text-align: center;
color: #c3c3c3;
text-shadow: 0 1px 0 #000;
}
nav.page-nav a:first-child {
border-left-width: 1px;
border-left-color: #3d3d3d;
}
nav.page-nav a:hover {
color: #e4e4e4;
background-color: black;
}
nav.page-nav .active {
color: white;
background: -ms-linear-gradient(#c95656, #8d0606);
background: linear-gradient(#c95656, #8d0606);
}
nav.page-nav .active:hover {
color: #fff;
}
nav.page-nav .active:before {
position: absolute;
top: 6rem;
display: block;
height: 0;
width: 0;
margin-left: -1.9rem;
border-top: 2rem solid #8d0606;
border-right: 6.5rem solid transparent;
content: "";
}
nav.page-nav .active:after {
position: absolute;
display: block;
height: 0;
width: 0;
margin-left: 4.3rem;
border-top: 2rem solid #8d0606;
border-left: 6.5rem solid transparent;
content: "";
}
<nav class="page-nav">
<div class="container">
Home
About
Schedule
Register
</div>
</nav>
I am confused with the display: block in the nav.page-nav a selector. If I change it to display: inline-block nothing change. Why?
I am also confused with the :before and :after. How do they work in the above code? I mean before supposed to be before the element no bellow it. They are shown bellow each active element.
The most common difference between display:block and inline-block is there alignment.
Display:Block by default takes full width and assigned height to there elements. Placement of display:block elements are one after another, whereas to align them in one line i.e. horizontally we need to use float:left, but display:inline-block elements are by default align in inline no need to used float:left.
Pseudo ::before - is used to assign some content or some style properties before the targeted element, but as you have assigned top:6rem to nav.page-nav .active:before so your before element is at bottom of target element.
Pseudo ::after - is used to assign some content or some style properties after the targeted element.
nav.page-nav {
background-color: #1d1d1d;
line-height: 6rem;
font-size: 1.7rem;
}
/* TODO: nav.page-nav .container */
nav.page-nav .container {
display: -ms-flexbox;
}
/* TODO: nav.page-nav a */
nav.page-nav a {
display: block;
width: 9rem;
padding: 0 1.8rem;
border-right: 1px dotted #3d3d3d;
text-decoration: none;
text-transform: uppercase;
text-align: center;
color: #c3c3c3;
text-shadow: 0 1px 0 #000;
position:relative;
}
/* TODO: nav.page-nav a:first-child */
nav.page-nav a:first-child {
border-left-width: 1px;
border-left-color: #3d3d3d;
}
/* TODO: nav.page-nav a:hover */
nav.page-nav a:hover {
color: #e4e4e4;
background-color: black;
}
/* TODO: nav.page-nav .active */
nav.page-nav .active {
color: white;
background: -ms-linear-gradient(#c95656, #8d0606);
background: linear-gradient(#c95656, #8d0606);
}
/* TODO: nav.page-nav .active:hover */
nav.page-nav .active:hover {
color: #fff;
}
/* TODO: nav.page-nav .active:before */
nav.page-nav .active:before {
position: absolute;
top:6rem;
left:0;
display: block;
height: 0;
width: 0;
border-top: 2rem solid #8d0606;
border-right: 6.5rem solid transparent;
content: "";
}
/* TODO: nav.page-nav .active:after */
nav.page-nav .active:after {
position: absolute;
display: block;
height: 0;
width: 0;
border-top: 2rem solid #8d0606;
border-left: 6.5rem solid transparent;
content: "";
bottom:-2rem;
right:0;
}
<nav class="page-nav">
<div class="container">
Home
About
Schedule
Register
</div>
</nav>
I want to add an icon (a small triangle) under a link using the CSS :after attribute, It works in Chrome but not in Firefox and IE. Here is the result in chrome:
but in IE and firefox here is the result:
The CSS code:
li.ui-state-active > a:after {
width: 22px;
height: 19px;
position: absolute;
display:block !important;
left: 50%;
margin-left: -11px;
bottom: -19px;
z-index: 2;
content: '';
**background-image: url(#{resource['img:css/arrow-menu-onglet.png']}) no-repeat !important;**
}
also I tried this but with the same result (ok in just chrome):
li.ui-state-active > a:after {
width: 22px;
height: 19px;
position: absolute;
display:block !important;
left: 50%;
margin-left: -11px;
bottom: -19px;
z-index: 2;
**content: url(#{resource['img:css/arrow-menu-onglet.png']}) no-repeat !important;**
}
Can you help me please figure out why?
No image needed:
/* tabbed nav */
nav ul {
list-style: none;
}
nav li {
display: inline-block;
}
nav li a {
position: relative;
display: inline-block;
padding: 15px 25px;
background: #fff;
margin-right: 4px;
margin-bottom: 7px;
}
nav li a.state-active:after,
nav li a.state-active:before {
content: " ";
position: absolute;
z-index: 1;
left: 0;
right: 0;
margin: 0 auto;
width: 0;
}
nav li a.state-active:after {
bottom: -15px;
border-top: 15px solid #fff;
border-left: 15px solid transparent;
border-right: 15px solid transparent;
}
nav li a.state-active:before {
bottom: -23px;
border-top: 23px solid #DBD5C7;
border-left: 23px solid transparent;
border-right: 23px solid transparent;
}
/* ----- */
* {
margin: 0;
padding: 0;
}
body {
margin: 20px;
background: #DBD5C7;
}
div {
background: #fff;
height: 100px;
}
<nav>
<ul>
<li>LINK 1
</li>
<li>LINK 2
</li>
<li>LINK 3
</li>
</ul>
</nav>
<div></div>
Site in question: http://khill.mhostiuckproductions.com/siteLSSBoilerPlate/
If you test the above link in IE7 (I am using IE9 with browsermode and browser compatability for IE7), there is a positioning problem with the subnavs.
Hover over about us, then hover over home, and then go back to About us. You will see the sub-nav has moved to the right by the width of the LI above it.
This is coded purely in CSS. This works perfectly in all browsers except for IE7, I would like to keep this working within CSS, without any Javascript fixes.
I also have a z-index issue, any ideas on these two issues?
Here is the CSS code that handles the main UL and LI, as well as the CSS that handles the first Subnav. (note the secondary subnav under "Michael" works as intended).
***Note that the class .main-nav is applied to the first UL that handles the horizontal bar. The class .main-sub-nav is applied to the UL that holds the subnav LI's Michael, Kenny etc. under the About us menu.
nav .main-nav {
position: absolute; /* allows us to absolute position the subnavs */
display: block;
width: 100%;
height: 40px; /*height of inner nav for white border */
padding: 0;
margin: 0;
border: 1px solid #fff; /* Inner white border */
-moz-border-radius: 5px; /*rounded edges */
-webkit-border-radius: 5px;
border-radius: 5px;
}
nav ul > li {
display: inline-block;
height: 40px;
padding: 0;
margin: 0 0 0 -4px;
}
/* MAIN NAV SUBNAV STYLES */
.main-sub-nav { /* BASIC STYLING PLUS HIDE */
position: absolute;
display: none;
z-index: 1;
width: 200px;
height: auto;
top: 100%;
border: 1px solid #d4d4d4;
background: #f6f6f6;
}
nav ul > li:hover > .main-sub-nav { /* ON HOVER MAKE SUB-NAV VISIBLE */
display: block;
}
nav ul li .main-sub-nav li {
position: relative;
height: 40px;
display: block;
padding: 0;
margin: 0;
border-top: 1px solid #fff;
border-right: none;
border-bottom: 1px solid #f2f2f2;
border-left: 1px solid #fff;
}
The thing is that you are incorrectly using positioning.
Try this approach. I have commented few changes.
.row.margin-bottom-15.nav-container { /* Remove overflow:hidden; so your dropdowns will be shown when they overflow. */}
nav .main-nav {
/* removed position:absolute; */
display: block;
width: 100%;
height: 40px;
padding: 0;
margin: 0;
border: 1px solid #fff;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
border-radius: 5px;
}
nav ul > li {
position: relative; /* Add position:relative; so you can absolute position dropdowns */
display: inline-block;
height: 40px;
padding: 0;
margin: 0 0 0 -4px;
}
.main-sub-nav {
position: absolute;
display: none;
z-index: 1;
width: 200px;
height: auto;
top: 100%;
left: 0;
border: 1px solid #d4d4d4;
background: #f6f6f6;
}
nav ul > li:hover > .main-sub-nav {
display: block;
}
nav ul li .main-sub-nav li {
position: relative;
height: 40px;
display: block;
padding: 0;
margin: 0;
border-top: 1px solid #fff;
border-right: none;
border-bottom: 1px solid #f2f2f2;
border-left: 1px solid #fff;
}
Let me know if it helped.