CSS Transitions firing on page load - html

I'm writing a simple website and have pretty much the same issue as described in these two posts:
Stop CSS transition from firing on page load
Chrome transition fires on page load when form element added
The issue is aparent when testing in Brave Browser, not for example in Edge. Although I have not used any <form> tag in my site..
Anyway, I can resolve this issue as described in those posts by putting a <script> </script> into the footer. My problem is, that I have a bad habit of letting VS Studio format my code with CTRL-K + CTRL + D, which will delete the space between the script tags. Also, copying the footer to a new file will do the same, thus I quite often have to resolve the same issue again and again.
Question now is: Since the linked posts are quite old therefore this issue has been known for quite a long time, is there another - better - way to resolve it?
Transition Code in Question:
nav {
position: relative;
background-color: #61625B;
width: 100%;
height: 100px;
}
nav ul {
position: absolute;
bottom: 0;
width: 70%;
list-style: none;
padding: 0 15%;
display: flex;
margin: 0;
}
nav li {
width: 125px;
text-align: center;
}
.navunderline {
width: 125px;
height: 0;
margin: 5px 0 0 0;
background-color: #DAD9D7;
transition: 500ms;
}
nav a {
color: #DAD9D7;
}
nav a:hover {
text-decoration: none;
}
nav li:hover .navunderline {
height: 5px;
margin: 0;
}
#selected .navunderline {
height: 5px;
margin: 0;
}
<nav>
<ul>
<li>Unternehmen<div class="navunderline"></div></li>
<li>Leistungen<div class="navunderline"></div></li>
<li>Referenzen<div class="navunderline"></div></li>
<li>News<div class="navunderline"></div></li>
<li>Kontakt<div class="navunderline"></div></li>
</ul>
</nav>

Related

Margin above and to the left and right of the header containing the navbar despite setting margin:0 explicitly

Navbar component-
body {
margin-top: 0;
padding: 0;
font-size: 18px;
}
.container {
width: 95%;
margin: 0 auto;
}
header {
margin-top: 0;
background: blue;
padding: 1em;
}
a {
color: white;
text-decoration: none;
}
a.logo {
font-weight: bold;
}
nav {
float: right;
}
ul {
list-style-type: none;
margin: 0;
display: flex;
}
li:hover {
filter: brightness(50%);
}
li a {
padding: 1em;
}
<header class="head">
<div class="container">
Home
<nav>
<ul>
<li> hello</li>
<li> whatsup</li>
</ul>
</nav>
</div>
</header>
<div class="container">
<router-outlet></router-outlet>
</div>
I am using chrome I notice a thin white strip of space at the top and the left and the right of the header component containing the navbar. How can i remove this such that the white space is replaced by navbar color ie. blue.
I am new at css, and Would be good if an explanantion of the cause could be provided.
Thanks
body {
display: block;
margin: 8px;
margin-top: 8px;
margin-right: 8px;
margin-bottom: 8px;
margin-left: 8px;
}
Added the css that displays on the inspect element for further clarity
I changed the margin-top:0 with the margin:0 for the body.
I hope it would work.
body {
margin: 0;
padding:0;
font-size: 18px;
}
Styling inline for body was one workaround that worked incase the browser doesnt recognize body css(assuming there wasnt any errors in the css ofcourse) and applies default styling.
From the update in your question where you show us the CSS being applied, as seen in the element inspector, we can see that your CSS is not being picked up by the browser at all.
Its difficult to tell why, but here are a few things that can help you fix it:
If it is in an external CSS file, check that the file is being included
Check for typos in the CSS for the body
Check for typos or misplaced } in any CSS before the body CSS - an error in preceding CSS could prevent the rest of the CSS in that file from being applied
Try adding that CSS directly into the HTML in a style tag to see if it works there... if so:
Try deleting the CSS and retyping it manually - Very occasionally I've seen issues where code copied from the internet or elsewhere can have hidden characters that cause problems.

Foundation 6 top bar left and right stack when I use a wrap class around top-bar-left and top-bar-right

So I'm using Foundation 6 to prototype a project and I'm noticing that top-bar, top-bar-left, and top-bar-right work just as shown on the docs page except when I want to wrap the left and right bars so that they don't touch the sides.
Both top-left-bar and top-right-bar take up the whole width of the top-bar area each and then end up stacking on top of each other. I want them to look like they do in the code pen link below:
(its linked with foundation 6.0.5, and I'm using 6.4.1 - couldn't find a link for that version)
https://codepen.io/mgrosen/pen/RgEVvY
relevant code from app.css
.wrap {
width: 90%;
max-width: 1100px;
margin: 0 auto;
}
.nav-desktop {
background-color: #222;
height: 80px;
padding: 0;
}
.site-logo {
color: white;
line-height: 80px;
}
.nav-desktop .menu-desktop {
line-height: 80px;
background-color: transparent;
}
.nav-desktop a {
display: inline-block;
}
.menu-desktop > li > a {
display: inline-block;
line-height: 80px;
padding-top: 0;
padding-bottom: 0;
color: white;
}
.menu-desktop > li > a:hover {
background-color: rgba(255,255,255, 0.1);
}
relevant index.html code
<nav class="top-bar nav-desktop" id="responsive-menu">
<div class="wrap">
<div class="top-bar-left">
<h3 class="site-logo">Site Logo</h3>
</div>
<div class="top-bar-right">
<ul class="menu menu-desktop">
<li>Home</li>
<li>About</li>
<li>Foundation Examples</li>
</ul>
</div>
</div>
</nav>
That's the actual code I'm using, but when open index.html to look at it (or run my flask application and view it on local host) this is what i see when I'm scrolled all the way to the top of the screen.
Anybody know why this is happening or how I might debug it with dev tools?
Thanks!

CSS Sprite navagation menu won't appear in any browser?

I am quite new to the world of HTML and CSS coding and am currently testing things out that I learn on my own website.
I have created a pretty simple nav menu I guess using CSS sprite coding, I am using Visual Studios 2012 and everything appears properly in that program, however when I try to test my webpage in any browser (IE, Google, Firefox) my nav menu just disappears. I notice that the cursor does change when I hover over the space where the nav menu should be, however as I said, no menu actually displays.
To add to that, other elements that I have in my page do appear and seem to function properly?
Here is the HTML code I am using
<div class ="navmenu">
<ul class ="navbar">
<li class ="Aboutus"></li>
<li class="Projects"></li>
<li class="Contactus"></li>
</ul>
</div>
and then the CSS
.navmenu
{
height: 120px;
position: relative;
}
.navbar
{
position: relative;
top: 0px;
left: 0px;
height: 79px;
}
.navbar li
{
list-style: none;
position: absolute;
margin: 0;
padding: 0;
top: 0;
}
.narbar li, .navbar a
{
height: 60px;
display: block;
}
.Aboutus
{
left: 0px;
width: 174px;
background: url('c:\users\teila\documents\visual studio 2012\Projects\Concept2\Concept2\Img\navMenu2.PNG') 0px 0px;
}
.Projects
{
left: 174px;
width: 174px;
background: url('c:\users\teila\documents\visual studio 2012\Projects\Concept2\Concept2\Img\navMenu2.PNG') -174px 0px;
}
.Contactus
{
left: 348px;
width: 174px;
background: url('C:\Users\Teila\documents\visual studio 2012\Projects\Concept2\Concept2\Img\navMenu2.PNG') -348px 0px;
}
.Aboutus a:hover
{
background: url('C:\Users\Teila\documents\visual studio 2012\Projects\Concept2\Concept2\Img\navMenu2.PNG') 0px -60px;
}
.Projects a:hover
{
background: url('C:\Users\Teila\documents\visual studio 2012\Projects\Concept2\Concept2\Img\navMenu2.PNG') -174px -60px;
}
.Contactus a:hover
{
background: url('C:\Users\Teila\documents\visual studio 2012\Projects\Concept2\Concept2\Img\navMenu2.PNG') -348px -60px;
}
I've tried looking for days as to what the problem could be, hopefully somebody could help me out. It would be greatly appreciated.
It may be because you have an absolute path to the image with c:/ etc. If you use the relative path sp perhaps img/ or /img/ or ../img/ using ../ to step back however folders back you need to go to reach your image folder from the css file.

CSS drop-down menu fails to remain following hover activity

I'm currently working on a couple of drop-down menus on the following page:
http://icao.tungsten.hireserve-test.com/home.html
Originally, we only had one of these menus but our client has since changed their template and we now need to implement two drop-down menus. Previously this was done with jQuery hover() events which fired show() and hide() but now I have replaced this with CSS.
li.dynamic-children{
position: relative
}
li.dynamic-children ul{
display: none;
position: absolute;
}
li.dynamic-children:hover ul{
display: block;
left: -1px;
top: 18px;
position: absolute;
z-index: 100
}
li.dynamic-children:hover ul span{
width: 100%
}
The dropdown menu is displayed successfully on hover however because it is done with CSS there does not appear to be any way of ensuring that the drop-down persists when the user moves off of the link which triggers the drop-down. This means that the user cannot select any of the items in the dropdown menu rendering it useless.
Do any of you have any ideas as to how I can force the menu to persist long enough for users to be able to make a selection for the drop-down menus?
EDIT:
Based upon some of the code provided below I have now included the following CSS rules:
.s4-tn .horizontal ul.dynamic {
background-color: #ECF4FC;
border-top:4px solid #003D78;
margin: 0;
width: 255px;
z-index: 1000 !important;
}
.menu-horizontal li.static, .menu-horizontal a.static, .menu-horizontal span.static {
float: left;
padding-bottom: 5px;
}
These rules cause the menu to persist however in IE7 the drop-down menu now falls behind other elements on the page rendering it still useless in this browser. I have tried numerous z-index fixes to no avail.
try this one,
.s4-tn .horizontal ul.dynamic {
background-color: #ECF4FC;
border: 0 solid #003D78;
margin: 0;
width: 255px;
z-index: 101;
}
li.dynamic-children:hover ul {
display: block;
left: -1px;
position: absolute;
top: 22px;
}
Either 1 of the two:
Option 1 (Line 2840)
. .s4-tn li.static > .menu-item {
color: #3b4f65;
white-space: nowrap;
border: 1px solid transparent;
padding: 4px 10px;
display: inline-block;
height: 34px;
vertical-align: middle;
}
Option 2 (Line 99)
.s4-tn .horizontal ul.dynamic {
margin: 0 0 0 0;
border: 0px #003D78 solid;
width: 255px;
background-color: #ecf4fc;
}

What causes this weird display ? I suspect it might be CSS or a bug in Chrome OS X?

This is what the weird view looks like, in Chrome on OS X on first load:
That blue bar running right across the screen is actually the navigation bar that should be at the top of the screen. See below.
This is what the original view looks like, and this is what it reverts to - once I scroll down (so that portion of the screen disappears) and scroll back up:
Edit1: I don't even know what code to post, if any because it is kinda random. If you ask some questions though, maybe something might jump out and I will know what code to either post or look at.
Thanks.
Edit2: Here is the code for the div#navigation:
<div id="navigation">
<div id="quota-info">
Plan: Chameleon<br />
# of Projects: 2 / 20<br />
# of Clients: 2 / 15<br />
Storage: 10.8 MB / 10.0GB <br />
</div>
<div id="user-info">
<span class="username">Hi Test</span><br />
Name: Test User<br />
Email: test#abc.com<br />
Last Logged In: about 2 hours ago<br />
</div>
<ul>
<li><img src="logo.png" /></li>
<li id="dashboard">Dashboard</li>
<li id="settings">Settings</li>
<li id="logout">Logout</li>
</ul>
</div>
Here is the CSS:
#navigation {
font-family: Verdana, Arial, sans-serif;
font-size: 13px;
background: #2d343f;
background-image: url('../images/nav-textured-bg.png');
background-repeat: repeat;
padding: 5px 5px;
margin: 0px auto;
position: relative;
height: 75px;
}
#navigation a {
text-decoration: none;
padding: 10px 15px;
display: inline;
height: 35px;
line-height: 35px;
color: #c6c8cb;
}
#navigation ul {
width: 100%;
margin: 0 auto;
text-align: center;
}
#navigation li {
width: 100%;
display: inline;
list-style-type: none;
}
#navigation li img {
position: relative;
top: 15px;
}
Edit 3:
Here is another screenshot of how it looks when I scroll up. The top navigational bar is still there. This blue thing is not even the menu, it's like a screenshot of it. When I hover over the menu links, they don't work.
You have to create a reduction. Start with a copy of the actual page and then remove stuff not related to the problem, one by one, until it disappears. Then you'll see what's causing it, whether it's a browser bug and what you can do to fix it.
PS: If it's a browser bug, don't neglect to report it. It's a web developer's responsibility.
I would start by cleaning up some of your CSS.
#navigation {
font-family: Verdana, Arial, sans-serif;
font-size: 13px;
background: #2d343f;
background-image: url('../images/nav-textured-bg.png');
background-repeat: repeat;
padding: 5px 5px;
margin: 0px auto; <--- see below
position: relative;
height: 75px;
}
this should be margin:0 since it's a block element. Block elements take up the entire line, so trying to center it makes no sense.
#navigation a {
text-decoration: none;
padding: 10px 15px;
display: inline; <--- conflict (see below)
height: 35px; <--- conflict (see below)
line-height: 35px;
color: #c6c8cb;
}
Inline elements can't have a width or height applied to them, but some browsers when you try to will automatically convert any inline element to inline-block for you. If that is what you want, you should specify it, otherwise drop the height.
#navigation ul {
width: 100%;
margin: 0 auto; <-- see below
text-align: center;
}
Centering an item with 100% width does not make sense here
#navigation li {
width: 100%; <--- conflict
display: inline; <--- conflict
list-style-type: none;
}
#navigation li img {
position: relative;
top: 15px;
}