Pretty simple but odd bug, I have a pseudo-element which is appearing fine on desktop browsers but disappears on mobile Chrome (not sure about iOS, no iPhone to test with)
Here's the basic CSS:
a {
text-decoration: none;
display: inline-block;
color: #000;
overflow: visible;
}
a::after {
content: '';
display: block;
height: 8px;
width: 98%;
background: #8BC8F690;
margin-top: -9px;
margin-left: 2px;
}
<a>hello</a>
jsfiddle:
https://jsfiddle.net/w4d1jteb/
Check your background. This is not a valid value. It's 8 chars long, but only can have 6.
a {
text-decoration: none;
display: inline-block;
color: #000;
overflow: visible;
}
a::after {
content: '';
display: block;
height: 8px;
width: 98%;
background: #8BC8F690; <-- This is not valid. *1*2
margin-top: -9px;
margin-left: 2px;
}
*1: You could try background-color: rgba(139, 200, 246, 0.565) instead.
*2: Or just use #8BC8F6.
See these examples below:
a {
text-decoration: none;
display: inline-block;
color: #000;
overflow: visible;
}
a::after {
content: '';
display: block;
height: 8px;
width: 98%;
background-color: rgba(139, 200, 246, 0.565);
margin-top: -9px;
margin-left: 2px;
}
#test {
text-decoration: none;
display: inline-block;
color: #000;
overflow: visible;
}
#test::after {
content: '';
display: block;
height: 8px;
width: 98%;
background: #8BC8F6;
margin-top: -9px;
margin-left: 2px;
}
<a>hello</a>
<a id="test">hello2</a>
Related
I need help making my navigation bar mobile friendly.
I tried following a few tutorials, but none of them worked.
Here's the web site's link (for the HTML) and here's the link to the CSS code.
I've tried using the #media tag, but it doesn't seem to apply to any of the content inside of the #media tag.
Here's the Media query for the CSS code:
```#media screen and (min-width: 800px) {
.nav-toggle-label {
display: none;
}
header {
z-index: 999;
width: 100%;
right: 0%;
top: 0%;
position: fixed;
}
.logo {
margin: 0;
color: silver;
list-style: none;
padding-top: 15;
}
.nav {
text-transform: uppercase;
font-size: 1.2rem;
background: var(--background);
}
.nav::after {
content: "";
display: table;
clear: both;
}
.nav-main {
float: right;
list-style: none;
}
.nav-main-item {
display: inline-block;
width: 10rem;
position: relative;
}
.nav-main a {
text-align: center;
padding: 1rem;
color: white;
text-decoration: none;
display: block;
}
.nav-main-item a:hover {
background-color: silver;
}
.nav-main-item:hover > .navi-main-item {
display: inline-block;
margin: 0;
}
.navi-main-item {
display: none;
position: absolute;
width: 100%;
top: 100%;
z-index: -1;
background: var(--background);
box-shadow: 0px 5px 10px rgba(0, 0, 0, 0.8);
}
.Discord {
padding-left: 72%;
margin-bottom: 80px;
}
.gif-Destiny {
width: 200px;
float: right;
color: white;
text-shadow: 2px 2px black;
}
.Zachary {
color: white;
text-decoration: none;
text-shadow: 2px 2px black;
}
.introduction {
color: white;
text-shadow: 2px 2px black;
}
.footer {
background-color: #1F2E4B;
color: white;
text-align: center;
font-size: 20px;
float: center;
margin-top: 12.5%;
}
.CbZD{
color: #00FFFF;
font-size: 30px;
}
}```
Have you tried Boostrap. It will give you a Headstart.
visit https://getbootstrap.com/docs/4.0/components/navbar/
I am making a navigation menu (following a tutorial), and to make the nav-icon I apparently have to use pseudo elements. Normally that would be fine, but this time, they wont show at all...
Is there something wrong with my code/is there a better way to make the icon?
*,
*::before,
*::after {
box-sizing: inherit;
padding: 0;
margin: 0;
}
body {
padding: 0;
margin: 0;
background-color: #FFF
-webkit-font-smoothing: antialiased;
}
a {
color: hsla(37, 39%, 72%, 1.00);
text-decoration: none;
}
li{
list-style: none;
}
.header {
width: 100vw;
height: 100vh;
display: block;
background:url(img/background.jpg) no-repeat center center;
background-size: cover;
position: relative;
}
.logo {
font-size: 4em;
color: #FFF;
line-height: 1.1;
border: 1px solid #fff;
border-radius: 100%;
width: 80px;
height: 80px;
display: inline-block;
padding: 5px;
background-color: hsla(152, 40%, 20%, 1.00);
margin: 50px 0 0 50px;
cursor: pointer;
}
.nav-icon {
width: 50px;
height: 40px;
display: block;
background-color: transparent;
position: absolute;
top: 70px;
right: 50px;
cursor: pointer;
-webkit-user-select: none;
-moz-user-select: none;
-o-user-select: none;
user-select: none;
}
.nav-icon .icon {
width: 50px;
height: 2px;
display: block;
background-color: #333;
position: absolute;
top: 20px;
}
.nav-icon .icon::before
.nav-icon .icon::after {
content: "";
width: 50px;
height: 2px;
display: block;
background-color: #FFF
position: absolute;
height: 100%;
}
.nav-icon .icon::before {
top: -10px;
}
.nav-icon .icon::after {
top: 10px;
}
You have missed semicolon ; in some lines and comma , in
.nav-icon .icon::before ,
.nav-icon .icon::after {
content: "";
width: 50px;
height: 2px;
display: block;
background-color: #FFF
position: absolute;
height: 100%;
}
that fixes what u were looking for
I am using custom CSS to style radio boxes but now the problem is that
checked radio circle is appearing at diff positions in IE11, FF36 and Chrome. Below is the illustration
CSS used to achieve this is as below:
label {
display: inline-block;
cursor: pointer;
position: relative;
padding-left: 32px;
}
input[type=radio] {
display: none;
}
label:before {
content: "";
display: inline-block;
width: 23px;
height: 22px;
margin-right: 10px;
position: absolute;
left: 0;
border:1px solid $grey;
border-radius: 50px;
}
input[type=radio]:checked + label:before {
content: "\25CF";
border:1px solid $light-blue;
color: $light-blue;
font-size: 26px;
text-align: center;
line-height: 0rem;
padding-top: 7px;
}
Any ideas please to work it same in all browsers..
I changed the approach. Instead of using content and line height, i switched as below
label:before {
content: "";
display: inline-block;
width: 20px;
height: 20px;
margin-right: 10px;
position: absolute;
padding:1px;
left: 0;
border:1px solid black;
border-radius: 50px;
}
input[type=radio]:checked + label:before {
border:1px solid blue;
background-color:blue;
box-shadow: 0 0 0 3px #fff inset;
width: 20px;
height: 20px;
}
JS Fiddle
I want to get some practice with pseudo elements in combination with transitions and animations. But I have one little problem.
Have a look at this:
HTML:
<nav id="navBar" class="clearfix">
Test
</nav>
CSS:
.clearfix:after {
content: ".";
clear: both;
display: block;
visibility: hidden;
height: 0px;
}
#navBar {
width: 100%;
padding: 30px;
border-top: 1px solid #808080;
border-bottom: 1px solid #808080;
box-sizing: border-box;
}
#navBar a {
text-decoration: none;
display: inline-block;
}
a.nav {
padding: 10px;
background-color: #7492b6;
color: #fff;
float: left;
font-weight: bold;
font-size: 1em;
min-width: 150px;
text-align: center;
}
a.nav::before {
content: "";
display: block;
position: relative;
top: 0;
left: 0;
width: 100%;
height: 3px;
background-color: #fff;
padding: 0;
}
a.nav::after {
content: "";
display: block;
position: relative;
top: 0;
left: 0;
width: 100%;
height: 3px;
background-color: #fff;
padding: 0;
}
http://codepen.io/anon/pen/rVbeLa
the two red lines are my pseudo elements. But I want them to have width 100% but it's not working in combination with the padding.
It should look like this but then I have no padding :/
http://codepen.io/anon/pen/RPOaRj
I have tested it on Firefox 39 and Chrome 43, both on OSX yosemite. Result is the same on both.
Any Idea how this problem could be solved?
Cheers
You can fix that by doing this.
Add position:relative; to the <a>:
#navBar a {
text-decoration: none;
display: inline-block;
position:relative;
}
Then, change your :before and :after to position:absolute; and change their position from top and bottom:
.navGroup1 a.nav::before {
content: "";
display: block;
position: absolute;
top: 10px;
left: 0;
width:100%;
height: 3px;
background-color: red;
}
.navGroup1 a.nav::after {
content: "";
display: block;
position: absolute;
bottom:10px;
left: 0;
width: 100%;
height: 3px;
background-color: red;
}
Updated Codepen
I am using a ul & li a bit like a select dropdown to trigger a JS function (not shown).
It's working fine - except the menu items appear BEHIND divs that are shown below them.
I've mocked up the problem here: http://jsfiddle.net/bf8ugef7/1/
I'm fiddling with z-index and position:absolute but can't see how to make it work.
Can anyone help?
Here is the HTML and CSS:
body {
font-family: sans-serif;
color: gray;
font-weight: 100;
}
div, li {
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
-ms-box-sizing: border-box;
box-sizing: border-box;
}
li {
color: #333333;
text-decoration: none;
/* background-image: url("images/mullion.gif"); */
}
div.images {
border: 1px solid #555555;
/* padding-left: 5px; */
width: 100%;
float: left;
clear: left;
margin-bottom: 20px;
/*
background-image: url("images/iMullion.gif");
background-repeat: no-repeat;
*/
}
div.lowerText {
width: 100%;
}
div.btn {/* +filter */
float: right;
width: 195px;
cursor: default;
text-align: right;
/* margin-left: 1px; */
display: inline-block;
}
div.btn1 {
float: left;
width: 153px;
cursor: default;
text-align: center;
margin-left: 1px;
display: inline-block;
position: absolute;
color: black;
background-color: #79c1ee;
left: 182px;
}
div.btn2 {
float: left;
width: 20px;
display: inline-block;
color: white;
font-weight: 100;
text-align: center;
background-color: white;
cursor: default;
position: absolute;
left: 162px;
z-index: 100;
}
div.btn2 ul {
list-style: none;
position: absolute;
display: block;
margin: 0px;
padding: 0px;
z-index: 100;
}
div.btn2 ul li {
display: none;
cursor: pointer;
color: white;
height: 25px;
background-color: #79c1ee;
margin-top: 1px;
z-index: 100;
}
div.btn2 ul li:first-child {
margin-top: 0px;
display: inline-block;
width: 20px;
z-index: 100;
}
div.btn2 ul:hover {
height: 200px;
}
div.btn2 ul:hover li {
display: block;
z-index: 100;
}
div.btn2 ul li:hover {
background-color: #13A3E2;
z-index: 100;
}
/*
div.btn2 ul li:hover {
display: block;
width: 20px;
height: 100px;
}
*/
div.btn3 {
margin-left: 1px;
float: left;
width: 20px;
display: inline-block;
vertical-align: top;
text-align: center;
font-weight: 400;
color: white;
background-color: #13A3E2;
position: absolute;
left: 336px;
cursor: pointer;
}
div.btn3:hover {
background-color: red;
}
div.btn4 {
/* border: 1px solid black; */
padding-left: 5px;
float: left;
width: 153px;
display: inline-block;
color: #444444;
cursor: default;
background-color: white;
}
div.attr {
padding-left: 5px;
color: #444444;
background-color: #79C1ED;
float: right;
clear: none;
display: inline-block;
text-align: left;
}
div.filters {
width: 100%;
line-height: 1.8;
overflow: hidden;
display: block;
font-size: 14px;
text-decoration: none;
float: left;
}
div.toptext {
line-height: 2.2;
display: block;
max-height: 35px;
color: #444444;
background-color: #555555;/* matches border color */
color: white;
width: 100%;
padding-left: 5px;
cursor: not-allowed;
/* border: 1px solid pink; */
}
div.leftnav {
width: 350px;
float: left;
clear: left;
}
div#container {
padding: 0px;
margin: 0px;
}
<div class="leftnav">
<div class="images">
<div class="toptext">Filters
<div class="btn">+ filter</div>
</div>
<div id="container">
<div class="filters rem" id="f12">
<div class="btn4" id="b4f12">Pupil name</div>
<div class="btn2" id="b2f12">
<ul>
<li id="ddf_12_0">=</li>
<li id="ddf_12_1">></li>
</ul>
</div>
<div class="btn1" id="b1f12">Joe Bloggs</div>
<div class="btn3" id="if12">x</div>
</div>
<div class="filters rem" id="f13">
<div class="btn4" id="b4f13">Pupil name</div>
<div class="btn2" id="b2f13">
<ul>
<li id="ddf_13_0">=</li>
<li id="ddf_13_1">></li>
</ul>
</div>
<div class="btn1" id="b1f13">Bill Clinton</div>
<div class="btn3" id="if13">x</div>
</div>
</div>
</div>
</div>
Thanks
Emma
Try this code:
div.btn2 {
float: left;
width: 20px;
display: inline-block;
color: white;
font-weight: 100;
text-align: center;
background-color: white;
cursor: default;
left: 162px;
}
div.btn2 ul {
display: block;
margin: 0;
padding: 0;
}
div.btn2 ul li {
display: none;
cursor: pointer;
color: white;
height: 25px;
background-color: #79c1ee;
}
div.btn2 ul li:first-child {
display: inline-block;
border-top: none;
width: 20px;
}
div.btn2:hover li {
display: block;
position: absolute;
width: 20px;
border-top: 1px solid #fff;
}
div.btn2:hover li:first-child {
position: relative;
}
div.btn2 ul li:hover {
background-color: #13A3E2;
}
# Claudiu Yes it should be comment, but i dont have enough points to add comments
div.btn2 {
width: 20px;
display: inline-block;
color: white;
font-weight: 100;
text-align: center;
cursor: pointer;
left: 162px;
}
div.btn2 ul {
display: block;
margin: 0;
padding: 0;
}
div.btn2 ul li {
display: none;
cursor: pointer;
color: white;
height: 25px;
background-color: #79c1ee;
}
div.btn2 ul li:first-child {
display: inline-block;
width: 20px;
}
div.btn2:hover li {
display: block;
position: absolute;
width: 20px;
background: #000;
}
div.btn2:hover li:first-child {
position: relative;
}
div.btn2 ul li:hover {
background-color: #13A3E2;
}
i have updated the fiddle