So I have the exact same CSS3 transition in to places, just with different markup.
one is using just an image in an li wrapped in an anchor tag, and one is using an li tag with an anchor tag inside of that which wraps a figure and a figcaption..
here is the markup.
<ul class="teamProfiles">
<li>
<figure><img src="assets/images/players/playerKris.png" /><figcaption>Kris R</figcaption></figure>
</li>
<li>
<figure><img src="assets/images/players/playerKris2.jpg" /><figcaption>Kris R</figcaption></figure>
</li>
<li>
<figure><img src="assets/images/players/playerJake.jpg" /><figcaption>Jake C</figcaption></figure>
</li>
<li>
<figure><img src="assets/images/players/playerBacon.jpg" /><figcaption>Steven B</figcaption></figure>
</li>
<li>
<figure><img src="assets/images/players/playerJon.jpg" /><figcaption>John A</figcaption></figure>
</li>
<li>
<figure><img src="assets/images/players/playerAmy.jpg" /><figcaption>Amy A</figcaption></figure>
</li>
<li>
<figure><img src="assets/images/players/playerDarth.jpg" /><figcaption>You</figcaption></figure>
</li>
</ul>
here is the css for the markup shown above..
.teamProfiles {
width: 920px;
}
.teamProfiles > li {
float: left;
width: 65px;
height: 85px;
border: 3px solid #fff;
box-shadow: 0 0 4px rgba(0, 0, 0, .3);
margin-left: 3%;
display: inline-block;
}
.teamProfiles > li:first-child {
margin-left: 0;
}
.teamProfiles > li:last-child {
margin-right: 3%;
}
.teamProfiles figcaption {
padding-top: 4px;
}
.teamProfiles > li > a > figure {
width: 65px;
height: 65px;
}
.teamProfiles > li > a {
display: block;
height: 85px;
width: 65px;
text-decoration: none;
text-align: center;
font-family:"proxima-nova", "Helvetica Neue", Helvetica, Arial, sans-serif;
font-weight: 600;
font-size: .8em;
font-smooth: always;
-webkit-font-smoothing: antialiased;
color: #333;
position: relative;
overflow: hidden;
}
.teamProfiles > li > a::after {
content: attr(title);
background: rgba(0, 0, 0, .5);
display: inline-block;
position: absolute;
width: 65px;
height: 40px;
padding-top: 25px;
top: -20px;
left: 0;
color: #9ecd41;
-webkit-transition: all .5s ease-in-out .6s;
}
.teamProfiles > li > a:hover::after {
top: 0;
}
What the heck am I missing?! its driving me crazy not being able to figure it out..
and yes i'm aware its only got the -webkit-transition property. Thats cause i'm working in Chrome to figure it out.. I had them all and tried in every browser and nothing worked. So I just left this one and was gonna figure it out in Chrome first.
any help trying to spot my stupidity would be awesome! :)
Have you tried removing the ::after for the :hover pseudo?
Related
I am new in programming and I have a simple question: I want to make the words in this navigation bar be further from each other.
ul{
list-style-type: none;
margin: 0px;
padding: 0px;
width: 100%;
overflow: hidden;
top: 0;
position: fixed;
}
li{
float: right;
transform: translateX(-300px);
transform: translateY(-30px;);
}
li a{
display: block;
text-align:center;
padding: 12px 16px;
text-decoration: none;
color: #fff ;
font-size: 37px;
font-family: 'Alegreya', serif;
}
<div class="header">
<header class="title">CSS Tricks</header>
<ul>
<li>
Home
</li>
<li>
Contact
</li>
<li>
About
</li>
<li>
News
</li>
</ul>
</div>
I don't see the point of using transform.. use display: flex instead of float: right and if you would like to have it on the right side, do justify-content: flex-end. About your question, if it is having space between the <a> use the margin: 0 30px or if your meant between letters, do letter-spacing: 5px like in the example below..
ul {
list-style-type: none;
margin: 0;
padding: 0;
width: 100%;
overflow: hidden;
top: 0;
position: fixed;
display: flex;
}
li a {
display: block;
padding: 12px 0;
margin: 0 30px;
text-decoration: none;
color: #000;
font-size: 3em;
font-family: 'Alegreya', serif;
letter-spacing: 5px;
}
<div class="header">
<ul>
<li>Home</li>
<li>Contact</li>
<li>About</li>
<li>News</li>
</ul>
</div>
you have a typo on this property transform: translateY(-30px;);
it should be without ; after value -30px
👇
transform: translateY(-30px);
Currently you've got a padding of 16px on the sides of your hyperlink tags. Because it's on both the left and right sides, that adds up to 32px between the text of each. Increasing that value will increase the space between the links.
Adding padding or margin to the <li> elements would also work.
I am trying to make a dropdown box with submenus appearing horizontally, which can also scroll vertically.
I have gotten everything working except for the scroll.
.dropdown-container {
background: white;
border: 1px solid #666;
cursor: pointer;
line-height: 24px;
height: 24px;
position: relative;
width: 150px;
}
.dropdown-container a {
color: black;
padding: 0 10px;
text-decoration: none;
}
.dropdown-container:after {
color: #666;
content: '\f107';
font-family: FontAwesome;
position: absolute;
right: 2px;
top: 0px;
}
.dropdown-container:before {
content: attr(data-content);
padding: 0 10px;
}
.dropdown-container li > a:not(:only-child):after {
content: '\f105';
font-family: FontAwesome;
position: absolute;
right: 4px;
top: 0px;
}
.dropdown-container ul {
background: white;
border: 1px solid #666;
display: none;
right: 1px; /*Why is it being nudged 1px right relative to parent?*/
list-style: none;
margin: 0;
max-height: 80px;
overflow-x: visible;
overflow-y: auto; /*This is the problematic line, remove this and the rest works*/
padding: 0;
position: relative;
width: 100%;
}
.dropdown-container:hover > ul {
display: block;
}
.dropdown-container ul li {
background: white;
position: relative;
}
.dropdown-container ul li:hover {
background: rgba(173, 216, 230, 0.6);
}
.dropdown-container ul li:hover > ul {
display: block;
}
.dropdown-container ul ul {
display: none;
position: absolute;
left: 150px;
width: 150px;
top: -1px; /*Another 1px adjustment required, why aren't they already aligned?*/
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
<div class="dropdown-container" role="nav" data-content="Title">
<ul class="dropdown">
<li>
Select 1
</li>
<li>
Select 2
<ul>
<li>
Select 2.1
<ul>
<li>
Select 2.1.1
</li>
</ul>
</li>
<li>
Select 2.2
</li>
</ul>
</li>
<li>
Select 3
</li>
<li>
Select 4
</li>
</ul>
</div>
See JSfiddle here.
But if I set overflow-y on the <ul> to auto to enable scrolling then my submenus get hidden as in the snippet above.
I believe the problem is the same as in this question: when overflow-y: auto and overflow-x: visible, overflow-x is treated as auto too.
Unfortunately the solution suggested (wrapping the <ul> in a position: relative element) has not worked for me.
Does anyone know of another way around this?
Please read my profile before proceeding. Anyone who doesn't keep the critique to only the code itself will be disregarded. Okay? Okay.
I'm trying to do tooltips to my navigation header, using the code on this page. The bottom tooltip, specifically.
I've snagged out the relevant parts of code from my own CSS and webpage to tool around with in their Try It Editor to get it working, and I've been cussing at this since last week and this is the furthest I've gotten to making it work, and even that came with some sacrifices in design I'm not sure how to fix. I will admit that tooltips like this are a very new area for me, and I'm trying to learn a new thing, and it's making me give it a very salty side-eye. So pointers to where I'm going wrong and what I need to be doing to correct it are what I'm looking for. Links to any sites that explain this better would also be tremendously appreciated.
<!DOCTYPE html>
<html>
<style>
body {
margin: 0px;
padding: 0;
background-color: #000000;
background-image: url(http://www.metathriving.com/img/index2bg.png);
background-repeat: no-repeat;
background-attachment: fixed;
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
color: #72809F;
}
/* Header */
#header {
width: 960px;
height: 160px;
margin: 0px auto;
background-color:rgba(0,0,0,0.5);
}
/* Boy Without A Fairy */
#navi {
float: left;
width: 900px;
height: 55px;
}
#navi ul li {
margin: 0;
padding: 0px 0px 0px 0px;
list-style: none;
line-height: normal;
}
#navi a {
display: block;
float: left;
height: 45px;
padding-left: 5px;
padding-right: 5px;
text-decoration: none;
text-align: center;
font-family: Arial, Helvetica, sans-serif;
font-size: 10px;
color: #578fa8;
}
#navi a:hover {
color: #9dd0ed;
}
#navi a.active {
color: #FFFFFF;
}
.tooltip {
position: relative;
display: inline-block;
border-bottom: 1px dotted black;
}
.tooltip .tooltiptext {
visibility: hidden;
width: 120px;
background-color: #c0c0c0;
color: #000000;
text-align: center;
border-radius: 6px;
padding: 5px 0;
position: absolute;
z-index: 1;
top: 150%;
left: 50%;
margin-left: -60px;
}
.tooltip .tooltiptext::after {
content: "";
position: absolute;
bottom: 100%;
left: 50%;
margin-left: -5px;
border-width: 5px;
border-style: solid;
border-color: transparent transparent #ffffff transparent;
}
.tooltip:hover .tooltiptext {
visibility: visible;
}
</style>
<body>
<div id="header">
<!-- Hey! Listen! -->
<div id="navi">
<ul>
<li><span style="color:#c0c0c0; font-weight: bold;">Just Another<br>Brick in<br>the Wall</span></li>
<li><div class="tooltip">Weary Eyes Still<br>Stray to the<br>Horizon <span class="tooltiptext">More About Me</span><div></li>
<li><span style="font-style: italic;">A Heavenly Ride<br>Through<br>Our Silence</span></li>
<li><span style="font-style: italic;">A Thousand<br>Miles of<br>Moonlight Later</span></li>
<li><span style="font-style: italic;">Trade Your Heroes<br>For Ghosts</span></li>
<li><span style="font-style: italic;">If You Can Hear<br>This Whispering<br>You Are Dying</span></li>
<li><span style="font-style: italic;">I'll See You On<br>the Dark Side<br>of the Moon</span></li>
<li><span style="font-style: italic;">Frontiers Shift<br>Like<br>Desert Sands</span></li>
<li><span style="font-style: italic;">You Are Only<br>Coming Through<br>In Waves</span></li>
</ul>
</div>
</body>
</html>
Here's a screencap of what that code renders in the w3schools.com Tryit Editor panel. (Ignore the font colors and the fact it's not easy to see in some spots because of text + background. the font will be tweaked when I have the layout done, I change up font colors as I work to make sure things are working and to single out stuff. And the full code does give a solid background under the text for better legibility.)
Screencap of what the code makes
As you can see, it line breaks. Where it does, the tool tip works. But it's not supposed to move the rest of it to a new line. At least, I don't want it to do that. I'm not sure where it's going off the rails here. Like I said, this is a new trick I'm trying to learn and I'm stumped, after a week of working, research, and several books studying. It's right in front of me, and it's gotta be bloody obvious, but what IS it?
Two issues:
There were a few tags in the tooltip incorrectly wrapped. Namely, <a></span></a></span>. I corrected this.
Then, the tooltip is causing the break you don't want. Add a float: left; to the .tooltip class.
body {
margin: 0px;
padding: 0;
background-color: #000000;
background-image: url(http://www.metathriving.com/img/index2bg.png);
background-repeat: no-repeat;
background-attachment: fixed;
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
color: #72809F;
}
/* Header */
#header {
width: 960px;
height: 160px;
margin: 0px auto;
background-color: rgba(0, 0, 0, 0.5);
}
/* Boy Without A Fairy */
#navi {
float: left;
width: 900px;
height: 55px;
}
#navi ul li {
margin: 0;
padding: 0px 0px 0px 0px;
list-style: none;
line-height: normal;
}
#navi a {
display: block;
float: left;
height: 45px;
padding-left: 5px;
padding-right: 5px;
text-decoration: none;
text-align: center;
font-family: Arial, Helvetica, sans-serif;
font-size: 10px;
color: #578fa8;
}
#navi a:hover {
color: #9dd0ed;
}
#navi a.active {
color: #FFFFFF;
}
.tooltip {
position: relative;
display: inline-block;
border-bottom: 1px dotted black;
float: left;
}
.tooltip .tooltiptext {
visibility: hidden;
width: 120px;
background-color: #c0c0c0;
color: #000000;
text-align: center;
border-radius: 6px;
padding: 5px 0;
position: absolute;
z-index: 1;
top: 150%;
left: 50%;
margin-left: -60px;
}
.tooltip .tooltiptext::after {
content: "";
position: absolute;
bottom: 100%;
left: 50%;
margin-left: -5px;
border-width: 5px;
border-style: solid;
border-color: transparent transparent #ffffff transparent;
}
.tooltip:hover .tooltiptext {
visibility: visible;
}
</style> <body> <div id="header"> <!-- Hey! Listen! -->
<div id="navi">
<ul>
<li><span style="color:#c0c0c0; font-weight: bold;">Just Another<br>Brick in<br>the Wall</span>
</li>
<li>
<div class="tooltip"><a href="about.html">Weary Eyes Still<br>Stray to the<br>Horizon <span class="tooltiptext">More About Me
</span></a>
</div>
</li>
<li><span style="font-style: italic;">A Heavenly Ride<br>Through<br>Our Silence</span>
</li>
<li><span style="font-style: italic;">A Thousand<br>Miles of<br>Moonlight Later</span>
</li>
<li><span style="font-style: italic;">Trade Your Heroes<br>For Ghosts</span>
</li>
<li><span style="font-style: italic;">If You Can Hear<br>This Whispering<br>You Are Dying</span>
</li>
<li><span style="font-style: italic;">I'll See You On<br>the Dark Side<br>of the Moon</span>
</li>
<li><span style="font-style: italic;">Frontiers Shift<br>Like<br>Desert Sands</span>
</li>
<li><span style="font-style: italic;">You Are Only<br>Coming Through<br>In Waves</span>
</li>
</ul>
</div>
I'm trying to create a very basic page of weblinks, arranged into 7 columns. Some of the links have sub-links. What I want to happen is when the mouse is held over a link that has sub-links, the sub-links are to appear just below it and just to the right (as shown in menu 2.2)
I've cobbled the code together from various websites (I'm not a coder!), and I'm almost there I think, but if you take a look at the jsfiddle you will see there is a problem with the 3rd column (I've cut the menu down in the example).
HTML
<div id="container">
<ul id="menu">
<li><h3>Menu 1</h3></li>
<li>1.1</li>
<li>1.2</li>
</ul>
<ul id="menu">
<li><h3>Menu 2</h3></li>
<li>2.1</li>
<li>2.2
<ul id="sub1">
<li>2.2.1</li>
<li>2.2.2</li>
<li>2.2.3</li>
</ul>
</li>
</ul>
<ul id="menu">
<li><h3>Menu 3</h3></li>
<li>3.1
<ul id="sub2">
<li>3.1.1</li>
<li>3.1.2</li>
<li>3.1.3</li>
</ul>
</li>
<li>3.2</li>
<li>3.3</li>
</ul>
CSS
a {
font-family: arial, helvetica, sans-serif;
font-size: 12px;
font-weight: 700;
text-decoration:none;
color:black;
display:block;
padding-top: 17px;
padding-bottom: 17px;
outline: 0;
}
a:visited {
color:black;
background-color:#fff;
}
a:hover {
color:#fff;
background-color:#302403;
display:block;
}
ul {
padding: 10px 0px 0px 0px;
margin: 1px;
display: inline-block;
text-align: center;
position:relative;
list-style-type:none;
float: left;
width: 160px;
background-color: #fff;
height: 400px;
}
ul#sub1 {
position: relative;
left: 30px;
top: -15px;
visibility: hidden;
height: auto;
padding: 0;
}
ul#sub2 {
position: relative;
left: 30px;
top: -15px;
visibility: hidden;
height: auto;
padding: 0;
}
ul#menu li:hover #sub1 {
visibility: visible;
height: auto;
z-index: 1;
border: 2px solid;
padding: 0;
}
ul#menu li:hover #sub2 {
visibility: visible;
height: auto;
z-index: 1;
border: 2px solid;
padding: 0;
}
http://jsfiddle.net/87u27aw0/
I can get it to work if I give each sub-menu it's own absolute position, but I'm sure there is a better way than how I'm doing it - using relative maybe? Oh, and it has to work in IE8 onwards.
Thanks in advance.
Graybags
Right now the parent menu has an opacity shift on hover, this is being transferred to the sub menu (current & previous) as well. I want the sub menu to have a clear background so that the opacity band of the parent is the only thing that is visible. Is there a way to use an li class for the submenu that makes it exempt from the li class that is governing the parent. I've been trying different things but can't seem to make it work properly.
Demo
HTML
<div>
<ul id="mainmenu">
<li class="liHome">
<a class="maintextcolour" href="#item-x1y1" id="Home" rel=
"none">INFO</a>
</li>
<li class="liServices">
<a class="maintextcolour" href="#item-x1y2" id="Services" rel=
"SubMenuY2">EXHIBITIONS</a>
<ul class="submenu" id="SubMenuY2">
<li class="sub1">
<a class="maintextcolour" href="#">CURRENT</a>
</li>
<li class="sub1">
<a class="maintextcolour" href="#">PREVIOUS</a>
</li>
</ul>
</li>
<li id="liEnvironment">
<a class="maintextcolour" href="#item-x1y3" id="Environment"
rel="none">CV</a>
</li>
<li id="liCareer">
<a class="maintextcolour" href="#item-x1y4" id="Career" rel=
"none">NEWS</a>
</li>
<li id="liContact">
<a class="maintextcolour" href="#item-x1y5" id="Contact" rel=
"none">MORE</a>
</li>
</ul>
</div>
CSS:
#charset UTF-8;
/* CSS Document */
body {
background-color: #666;
background-size: 100%;
background-repeat: no-repeat;
}
#mainmenu {
margin: 0;
padding: 0;
list-style-type: none;
position: relative;
}
#mainmenu li {
clear: left;
position: relative;
}
#mainmenu a {
display: block;
overflow: hidden;
float: left;
width: 100%;
position: relative;
opacity: 1;
-webkit-transition: all .4s ease-in-out;
padding-left: 20px;
}
#mainmenu li:hover a {
background-position: 0 0;
background-color: clear;
background-color: rgba(255,255,255,0.5);
width: 100%;
opacity: 0;
-webkit-transition: none;
}
#mainmenu li.active a {
background-position: 0 0;
background-color: clear;
width: 100%;
}
.submenu {
list-style-type: none;
float: left;
display: none;
position: absolute;
left: 135px;
top: 0;
width: auto;
}
#mainmenu li a:hover + .submenu,.submenu:hover {
display: block;
}
.submenu li {
display: inline-block;
clear: none !important;
}
.submenu li a {
float: right;
margin-left: 10px;
}
.maintextcolour {
font-family: Arial, Helvetica, sans-serif;
font-size: 24px;
color: #FFF;
text-decoration: none;
}
.maintextcolour:hover {
font-family: Arial, Helvetica, sans-serif;
font-size: 24px;
color: #0FF;
text-decoration: none;
}
.headertext {
font-family: Arial, Helvetica, sans-serif;
font-size: 14px;
color: #FFF;
text-decoration: none;
}
Here is the updated Fiddle link. I have just added color to the following css:
#mainmenu > li:hover > a {
background-position: 0 0;
background-color:clear;
color:#0fffff;
background-color:rgba(255,255,255,0.5);
width:100%;
\
opacity: 0;
-webkit-transition: none;
}
Hope you want this.