How to debug pseudo-elements such as hover? - css

I've been trying everything I could find on SO. Nothing is working. What I want to do is very simple and easy. I'm only wanting to highlight/change background-color of a button when the cursor is hovering but the mouseover effect is not working, no matter what I try. I will try to reproduce the environment by giving custom CSS and HTML. I also host Bootstrap and jQuery locally (not CDN) and they are both included in index.html.
index.html
<section class="sectionscreen" id="splash">
<div class="col-md-12">
<div class="row">
<div class="form">
<div class="center-text-screen">
<a id="loginBtnHover" href="login.html" class="btn-link-screen btn" data-translate="log_in">Login</a>
</div>
</div>
</div>
</div>
</section>
css
html,
body {
margin: 0;
font-size: 100%;
font-family: 'Lato', sans-serif;
background: #fff;
width:100%;
height:100%;
}
body a {
text-decoration: none;
transition: 0.5s all;
-webkit-transition: 0.5s all;
-moz-transition: 0.5s all;
-o-transition: 0.5s all;
-ms-transition: 0.5s all;
font-family: 'Lato', sans-serif;
}
body {
font: 1.3rem/1 "Avenir LT W02 45 Book",sans-serif;
color: #5c5c5f;
}
body img {
max-width: 100%;
}
a{
text-decoration: none;
color: inherit !important;
}
a:hover{
text-decoration: none !important;
}
#splash{
background-image: url("../images/splash.png"); /* The image used */
background-color: whitesmoke; /* Used if the image is unavailable */
height: 100%; /* You must set a specified height */
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
background-size: cover; /* Resize the background image to cover the entire container */
text-align: center;
padding: 2.5%;
}
.center-text-screen{
display:grid;
position: fixed;
left: 0;
right: 0;
margin-left: auto;
margin-right: auto;
width: 100%; /* Need a specific value to work */
/*height:200px !important;*/
bottom:8% !important;
color: #302b70;
}
.btn-link-screen{
background:#d9d9d9;
margin-bottom:1.5% !important;
width: 170px;
left: 0;
right: 0;
margin-left: auto;
margin-right: auto;
border-radius:50px !important;
color:#a6a6a6 !important;
}
This does not work :
.btn-link-screen:hover{
background-color:gold !important
}
Only works when computer is not connected to the internet, otherwise does NOT work
.center-text-screen .btn-link-screen:hover{
background-color:gold !important;//works when not connected to internet
}
OR
.center-text-screen a:hover{
background-color:gold !important;//works when not connected to internet
}
Does not work
#splash .center-text-screen .btn-link-screen:hover
does not work
#splash .btn-link-screen:hover
does not work
#splash a:hover
What am I doing wrong and how can I debug this?

Well, somewhere somehow, your styles are being overwritten by others in the cascade, which means your CSS is being read before the rules you're trying to rewrite. That's all that's happening.
First thing to check: make sure your stylesheet positioned after Bootstrap in your HTML.
If that's not it, which version of Bootstrap are you using?
Also, I notice you have an id there - loginBtnHover - have you tried that? That ID gives you a lot of specificity to target that element. An ID will supercede class rules.
Debugging hover states is available in every modern browser. I could try to describe where the button is to do this, but I think it would be faster/easier to find a YouTube on it for your browser of choice. But you can do it - there are options to toggle :hover, :focus, :active, etc in this menu, and it is very helpful.

Related

Animation from big font to small messes up the positioning

I am currently trying to make an animation with a welcome message. I want it to be placed in the verticalmiddle of my div. I transform it from a big font to a small font and it seems like the big fonts height is still affecting the positioning or am I wrong?
#barbar{
height:10%;
width: 100%;
background-color:rgba(79, 79, 90, 0.92);
bottom: 0;
position: fixed;
z-index: 3;
}
.hello{
color: black;
font-family: "Times New Roman";
text-align: center;
animation: ease;
animation-name: gas;
animation-iteration-count: 1;
animation-fill-mode: forwards;
animation-duration:2s;
position: fixed;
font-size: 100px;
bottom: 700px;
margin-left: -20%;
white-space: nowrap;
}
#keyframes gas{
from { font-size: 500px; bottom: 700px; margin-left: -20%;}
to { font-size: 12px; bottom: 0; margin-left: 15%;}
}
<div id = "barbar">
<h3 class ='hello'> Welocme User </h3>
</div>
As you can see my h3 is inside the div but it still somehow doesn't end up where I want it to be placed. to bottom:-x% is not the soulution im looking for.
Add "margin-bottom: 0;" to your h3 tag.
By default, the browser adds a margin of 1em to h3 elements. Since the "em" unit is relative to font-size, when you add "font-size: 100px" to your element you also get 100px of margin.
I suggest using a CSS reset. It will clear all the browser's defaults, preventing it to add unwanted styles on your page. It also makes sure that your page will look exactly the same in all browsers since different browsers use different defaults. I suggest using meyerweb reset on all your pages.

CSS button not working in Google Chrome?

I'm working on a home page for a film company's website, and it has a CSS button with a hover effect that is going to open a lightbox once it's ready, at the moment I just have it set to href="#" as a placeholder until I'm ready to implement the lightbox. There is also a small image of a downward pointing arrow, with the link set to an anchor that isn't on the page yet. Both of these work in Firefox, but in Chrome the hover effect doesn't work on the button, and it behaves as if neither of these elements have anchor tags around them. I poked around with Chrome's dev tools and it seems as though the span around the button may be the culprit as Chrome seems to be resizing it, but I can't figure out any reason why the image link isn't working, and I'm not entirely sure why Chrome is disagreeing with the span.
The strange part is that there are three other CSS buttons with hover effects in a seperate div, and they all work just fine.
The website is currently uploaded at http://www.gruntwork.us/reelindi/test/
The style sheet can be found at http://www.gruntwork.us/reelindi/test/reelindi.css
CSS:
div.header {
position:absolute;
top: 0;
left: 0;
right: 0;
background-image:url("resources/images/bg.jpg");
background-size:cover;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
height:430px;
width:100%;
z-index: -1;
}
img.arrow {
display: block;
margin-left: auto;
margin-right: auto;
margin-top: 58px;
z-index: 999;
}
span.redBtn a {
text-align:center;
display:block;
margin: 0 auto;
width: 150px;
margin-top: -40px;
z-index: 999;
}
a.redBtn {
color: #fff;
background-color: #d94d4d;
font-size: 1.125em;
padding: 8px 18px;
text-decoration: none;
text-align: center;
-webkit-transition: all ease 1s;
-moz-transition: all ease 1s;
-o-transition: all ease 1s;
-ms-transition: all ease 1s;
transition: all ease 1s;
border-radius: 5px;
}
a.redBtn:hover {
background-color: #bf3030;
}
HTML:
<div class="header">
<h1 class="header">Reel Indi</h1>
<h2 class="header">"Storytelling in motion."</h2><br>
<span class="redBtn">Push the red button!</span>
<img class="arrow" src="resources/images/arrow.png">
</div>
I've searched around but can't find an answer for this. Help?
Seems like your header's z-index: -1 rule pushes everything "behind" the body content, causing you not to be able to receive mouse events on that layer. Changing it to zero or higher will let you have hover effects and other events just fine.

My html page is not scrolling in browsers

The page on my website is not scrolling. If there are more content than screen can fit you can not actually see it because scroll is not working. I'm not and CSS guru and I don't know if the problem is actually with CSS or HTML.
I've spend some time trying to understand the problem but i'm not a CSS guru so I hope someone can help me. The page is using tweeter-bootstrap and custom theme for it (which i did not write). When I don't include theme CSS file scrolling is working fine.
Part of my theme CSS file:
body {
color: #000;
font-family: 'Play', sans-serif;
font-size: 16px;
line-height: 25px;
background: #e0dbcd url('../images/bg.jpg');
letter-spacing:0.2px;
overflow: hidden;
}
remove overflow: hidden; from body in the bootstrap-theme.css file.
For someone who was in my scenario, this could be happening because of height: 100% for html, body in angular-material.css. Remove it and you're good to go.
Remove overflow: hidden; from body as #Nabbit suggested or set overflow: scroll;
Edited:
The overflow property controls what happens to content that breaks outside of its bounds. By default, the property is visible i.e. content is not clipped when it proceeds outside its box.
overflow: hidden; means overflowing content will be hidden.
overflow: scroll; this is similar to hidden except users will be able to scroll through the hidden content.
This may not be relevant for anyone, but i'm going to comment it here anyway - I was using a
pseudo :after
element on the body, and had applied
position: fixed
below a certain viewpoint to the css, however I had put
.classname
and not
.classname:after
on the element. I'll post the CSS below. what this did was fix the position of the page so it could not scroll.
full CSS that's relevant:
body {
background-color: #5c2028;
color: #ffffff;
min-width: 100%;
min-height: 100%;
-webkit-box-sizing: border-box !important;
-moz-box-sizing: border-box !important;
-ms-box-sizing: border-box !important;
box-sizing: border-box !important;
overflow-x: hidden;
}
body.bg{
background-image: url('../img/background.jpg');
background-repeat: no-repeat;
background-position: center center;
background-size: cover;
background-clip: none;
min-width: 100%;
min-height: 100%;
width: auto;
height: auto;
}
body.bg:after{
content : "";
background-image: url('../img/hildasball_7_d_s_bg.jpg');
background-repeat: no-repeat;
background-position: center center;
background-size: cover;
background-clip: none;
display: block;
position: fixed;
top: 0;
left: 0;
opacity : 1.0;
z-index: -2;
min-width: 100%;
min-height: 100%;
width: 100%;
height: 100%;
/*width: auto;
height: auto;*/
}
#media (max-width: 767px) {
body{
min-height: 800px;
}
/* Initially, i put body.bg not body.bg:after, which made things not scroll and i ended up getting confused as hell */
body.bg:after{
position: fixed;
}
.floatContact {
float: none;
}
}
I agree will all above said, something to add I recently discovered in my code is the following CSS added.
* {
-moz-transition: .5s ease-in-out;
-webkit-transition: .5s ease-in-out;
transition: .5s ease-in-out;
}
This also can interfere with the HTML & body scrolling. So I would recommend adding this transition effect in the specific component you desire to have the effect rather than on the HTML & body.

Animation stop with css3

At the moment i am working on a header with a slider animation (css3 only):
http://jimmytenbrink.nl/slider/
Everything is working fine except sometimes the slider is bugging if you go from the center to the right. It seems that i need to stop the animation for a few miliseconds to complete. However i searched everywhere on the internet but i cant seem to get it to work.
Anyone here has experience with it who can help me out?
HTML
<header>
<div><span>slide 1</span></div>
<div><span>slide 2</span></div>
<div><span>slide 3</span></div>
<div><span>slide 4</span></div>
<div><span>slide 5</span></div>
<div><span>slide 6</span></div>
<div><span>slide 7</span></div>
<div><span>slide 8</span></div>
</header>
CSS
header {
margin-top: 10px;
width: 800px;
overflow: hidden;
height: 500px;
}
header div {
background-color: #000;
width: 43.8px;
height: 200px;
position: relative;
float: left;
-webkit-transition: width .3s;
transition: width .3s;
overflow: hidden;
-webkit-animation-timing-function: linear;
-webkit-animation-iteration-count: 1;
-webkit-animation-fill-mode: forwards;
margin-right: 2px;
}
header div:first-child {
margin-left: 0px;
}
header div:last-child {
margin-right: 0px;
}
header div:hover span {
left: 50px;
opacity: 1;
}
header div img {
position: relative;
left: -240px;
-webkit-transition: all .3s;
transition: all .3s;
-webkit-filter: grayscale(1);
overflow:hidden;
}
header div span {
-webkit-transition: left .3s;
transition: left .3s;
position: absolute;
bottom: 30px;
color: white;
left: -350px;
opacity: 0;
width: 450px;
font-family:'Fugaz One', cursive;
text-transform: uppercase;
font-size: 24px;
color: #fff;
text-shadow: 0px 0px 10px #f1f1f1;
filter: dropshadow(color=#f1f1f1, offx=0, offy=0);
}
header:hover > div {
width: 43.8px;
}
header:hover > div:hover {
width: 150px;
}
Here is a JSFiddle
So the question is, how can i set a stop on the animation for a few miliseconds so the animation can finish before it gets triggered again?
Hope my question is clear!
(thanks for the edit)
One might call my answer a workaround. Maybe it is but according to my comment on ExtPro's answer - it is still completely pure CSS.
I decided to use display: table-cell since the table cell's width is distributed equally.
So, the CSS might look like this:
HINT: This is only a bunch of necessary CSS. All the code is in the jsFiddle
header {
width: 368px;
display: table;
overflow: hidden;
}
header > div {
width: 44px;
height: 200px;
position: relative;
-webkit-transition: width .3s;
transition: width .3s;
display: table-cell;
overflow: hidden;
}
header > div:hover {
width: 151px;
}
Fiddle
As you can see, we don't have to determine the width of all not-hovered divs. Actually, the problem came from that very CSS rule:
/* DON'T USE THIS RULE - IT'S THE RULE WHICH WAS BAD */
header:hover > div {
width: 43.8px;
}
You were changing the width of the divs on header:hover, so when the transition didn't manage to do its job in time, you came out with mouse pointing to the header but to non of the divs.
If I understand what you mean by 'bugging', what is happening is if you move the mouse quickly to the right, it traverses the currently open div and is left in an area which when that div collapses, does not contain (e.g. the mouse is not hovered over) the next one in order to expand it- namely the hover event of the following div(s) is/are not firing thus they do not expand. There wont be a CSS fix for this Im afraid as its browser related, you may want to replace with jQuery/JS.

CSS blur filters breaking on scroll and hover

First time poster - I've looked everywhere for a solution and I'm hoping you guys can help! I'm having problems when using CSS blur filters. I have created a frosted glass effect (kind of similar to the ios7 settings menu effect) to provide an overlay on my site. I've noticed that the transparent div on top of the blurred div breaks whenever I interact with an element on it (in photo #1 hovering over a clickable icon). It also incurs horizontal lines breaking the effect when the nav covers and the uncovers the div on scroll (photo2). The trouble seems to be with the ".blur" div itself as I still see the same behavior on scroll when I remove the ".overview_text" text transparency overlay. Is this a bug with webkit filters itself, or something I've done wrong? Any ideas out there as to what might be causing this and how to prevent it from happening? Thanks in advance.
Image1: http://cl.ly/image/2v3p3P0r3d1y
Image2: http://cl.ly/image/2H091L2l1K2c
Relevant html.erb
<div class="plan_overview span10 offset1">
<%= image_tag plan.cover_photo, class: "panzoom-elements" %>
<div class="blur span3">
<%= image_tag plan.cover_photo %>
</div>
<div class= "overview_text span3">
...took out content code here...
</div>
css.scss file
.plan_overview {
height: 400px;
background: $gray;
z-index: 2;
margin-top:10px;
margin-bottom: 20px;
overflow: hidden;
border: 1px solid #979797;
img{
position:absolute;
overflow: hidden;
}
}
.blur{
position: absolute;
#include box_sizing;
z-index: 2;
height: 400px;
width: 300px;
margin-left:0px;
padding:0;
background-color: white;
img{
z-index: 2;
position: absolute;
height:420px;
width: 350px;
left: 0;
margin: -1px;
overflow: hidden;
filter: blur(30px);
-webkit-filter: blur(30px);
-moz-filter: blur(30px);
-o-filter: blur(30px);
-ms-filter: blur(30px);
}
}
.overview_text {
background: rgb(250, 250, 250); /* Fall-back for browsers that don't support rgba */
background: rgba(240, 240, 240, .5);
position: absolute;
margin-left: 0;
border-right: 1px solid #979797;
z-index: 10;
padding: 5px;
color: white;
font-family: AvenirNextCondensed-Regular;
word-break: normal;
word-wrap: break-word; /* IE */
height: 400px;
width: 300px;
font-size: 18px;
line-height: 25px;
float: left;
.title {
z-index: 301;
font-family: AvenirNextCondensed-Bold;
font-size: 20px;
line-height: 27px;
}
}
For anyone needing a solution in the future, I was able to solve this problem by forcing hardware acceleration. Added this to my .blur css:
-webkit-transform: translate3d(0,0,0);
-moz-transform: translate3d(0,0,0);
-ms-transform: translate3d(0,0,0);
-o-transform: translate3d(0,0,0);
transform: translate3d(0,0,0);
I couldn't reproduce this problem using Chrome 30. I used your code and it worked ok: http://cdpn.io/ilgsJ
Maybe you could post a codepen or a JSFiddler?
CSS filters are still experimental and have big chances to not work the way it was meant to. Avoid it by now unless your goal is to experiment.

Resources