I'm trying to edit some CSS (on a tumblr page) and I'm having a problem with an icon. It's the Twitter icon on the far right of this image
Above appears as split in half on the page.
I used the code below for all four of the icons ((just a different url for each image), yet I'm not sure why the Twitter one is split like that.
What could be the reason and how can I fix it?
Code:
#above-nav-links a.twitter:before {
background-image: url(http://imgh.us/twitter_icon_blue.svg);
content: ' ';
display: inline-block;
width: 25px;
height: 25px;
margin-right: 3px;
repeat: no-repeat;
}
If you copy-paste the background-image url, you can see the image I used for the icon (it is not split). The pages I used for the other icons are similar (in terms of spacing, size, etc.).
As I havn't seen your code, you can change your code accordingly
<ul id="#icons">
<li></li>
<li></li>
<li></li>
<li></li>
</ul>
<style type="text/css">
#icons > li
{
display: inline-block;
list-style:none;
float:left;
}
#icons > li > a
{
background-image: url("icons.png");
width: 25px;
display: inline-block;
height: 25px;
repeat: no-repeat;
}
#icons > li:nth-child(1) > a
{
background-position:2px -8px;
}
#icons > li:nth-child(2) > a
{
background-position:-29px -8px;
}
#icons > li:nth-child(3) > a
{
background-position:-61px -8px;
}
#icons > li:nth-child(4) > a
{
background-position:-97px -7px;
}
</style>
Background-positions are set according to my icon image. You may need to udpate as per your image.
Related
I have setup a list of tags inside an unordered list. I want this component to house a vertically aligned items on the side of the page.
It currently looks like below:
Here's how the sidebar is currently setup:
export default class SideBar extends PureComponent {
render() {
return (
<div className="sidebar-container">
<ul class="sidebar-list">
<li role="presentation" class="active">Home</li>
<li role="presentation">Profile</li>
<li role="presentation">Messages</li>
</ul>
</div>
);
}
}
with css
.sidebar-container {
position: absolute;
left: 0;
top: 0;
bottom: 0;
flex-shrink: 1;
z-index: 999;
// width: 20px;
}
.sidebar-container > ul {
list-style: none;
}
.sidebar-list > li {
-webkit-transform: rotate(180deg);
transform: rotate(180deg);
-webkit-writing-mode: vertical-lr;
-ms-writing-mode: tb-lr;
writing-mode: vertical-lr;
// background-color: pink;
color: white;
}
.sidebar-list > li > a {
color: red;
text-decoration: none;
text-transform: uppercase;
margin-top: 16px;
background-color: green;
font-size: 5vh;
}
How can I stick it to the left?
Browsers give uls a default padding (Chrome for example gives it 40px). You need to set that to 0 like this:
.sidebar-container > ul {
list-style: none;
padding: 0;
}
If I'm understanding correctly, couldn't you just used fixed?
.sidebar-container {
position: fixed;
top: 0;
left: 0;
}
It will be removed from the flex flow (I believe) so you might need to adjust some other bits and bobs based on that.
ul has default padding you need to override it.
See here. http://jsfiddle.net/bhupendra_nitt/1dxt36sb/6/
If you have not got a browser reset in your project you should do. Use normalize
https://necolas.github.io/normalize.css/ or something similar. Most of these issues will not be present for you after but I as everyone has said you need to remove the default padding from the ul
I have a purely .css driven menu. Currently, I have the flyout on the sub-sub menu appearing at 180px. This obviously doesn't work because as soon as menu text that exceeds 180px is entered, the submenu text is overlayed with the sub-submenu text (In the example, Highlighting Products > Entertainment Centers USA shows the problem).
The spot in the .css where I have explicitly stated the 180px width is below. I need it to be dynamic, i.e. the desired behavior is for the flyout to align with the right side of the first level vertical menu regardless of the first level submenu's width.
/* -- Appearance of second vertical dropdown menu unhovered (submenu of first level vertical menu) -- */
.rmenu li ul li:hover ul li a {
padding: 0px 0px 0px 5px;
background: #e8dec7; /*background color for submenu hovered text*/
color: #51db29; /* this is the color of the sub-sub menu text. I made the color (#51db29) 'unusual' as an example. Should be changed to something less jarring (of course) */
word-wrap: break-word;
min-width:100px;
position: relative; left: 180px; top: -35px; /* display 3rd level to the right (180px) */ /*left: 180px*/
}
The jfiddle is here:
http://jsfiddle.net/9c8wcxju/4/
Many, many thanks.....
I have simplified everything down and made this for you. You can expand on it and do what you want with it. I couldn't really work with yours, ended up deleting most of the css.
As you can see I have added class to each level of the sub-menu so it is easier to target. What I have created is what I think you wanted, I hope this puts you on the right track.
http://jsfiddle.net/9c8wcxju/5/
.rmenu ul li {
margin: 0;
padding: 0;
position: relative;
}
.rmenu ul {
list-style-type:none;
margin:0;
padding:0;
}
.rmenu li a {
display:block;
min-height: 35px;
line-height: 35px;
font-family: "Arial", sans-serif;
font-size: 18px;
color: #000000;
background-color: #e8dec7;
text-decoration: none;
white-space: nowrap;
}
.rmenu li:hover a {
background: #d6cbb0;
}
.rmenu .hidden {
display: none;
}
.rmenu .level_1 > li {
float: left;
}
.rmenu .level_1 > li a {
padding: 0 10px;
}
.level_1 > li:hover .level_2,
.level_2 > li:hover .level_3 {
display: block;
}
.level_2 {
position: absolute;
left: 0;
}
.level_3 {
position: absolute;
top: 0;
left: 100%;
}
At my website I would like to make the dots in the side change when I'm on the active div box. The hover works fine, but I can't get the active to work. The path for the image is worked fine, when I tried to put it under hover.
#nav{
z-index: 5;
position: fixed;
top: 50%;
right: 20px;
}
#nav li {
position: relative;
height: 20px;
width: 20px;
margin-bottom: 15px;
}
#nav li a {
display: block;
width: 20px;
height: 20px;
text-indent: -9999px;
background: transparent url('images/dot.png') no-repeat;
opacity: 0.80;
}
#nav li a:hover {
opacity: 1;
}
#nav li a:active {
background: transparent url('images/dotactive.png') no-repeat;
}
I don't think it's possible for the image to stay as the active background with just CSS alone. You will need to use a combination of javascript too.
With jQuery you could try something like the below.
.active{background: url('images/dotactive.png') no-repeat !important;}
$('#nav li a').live('click',function () {
$('.active').removeClass('active');
$(this).addClass('active');
});
EDIT A Workign fiddle of your site keeping the active nav background images. http://jsfiddle.net/ukCG8/
try this out
background: url('images/dotactive.png') no-repeat;
no need for transparent
or use opacity also for tranparency
Try this:
<script language="JavaScript" type="text/javascript">
/*<![CDATA[*/
var Lst;
function CngClass(obj){
if (Lst) Lst.className='';
obj.className='selected';
Lst=obj;
}
/*]]>*/
</script>
And modify the li items like this:
<li>
<a onclick="CngClass(this);" href="#">Test 1
</a>
</li>
I wish I could take credit for the fix; check it out in action here (yes, I'm cheating on stackOverflow with another web dev site!)
I'm in the process of making my own blog, I haven't got a domain yet so it's not live(I've been building the site from a folder with different directories as the pages). I've been working on the blog and I was looking for a simple navigation menu. I found one on the internet. I'm trying to center the navigation bar and I've tried many solutions that worked for other peoples websites but it isn't working for mine. This is the code (I've tweaked it to my own colors and nav titles)
<ul id="list-nav">
<li>Home</li>
<li>Books</li>
<li>About</li>
<li>Contact</li>
</ul>
And this is the CSS:
ul.list-nav {
list-style:none;
width:525px;
margin-right: auto;
margin-left: auto;
}
ul#list-nav li {
display:inline;
}
ul#list-nav li a {
text-decoration:none;
padding:5px 0;
width:150px;
background:#383838;
color:#eee;
float:left;
border-left:1px solid #fff;
}
ul#list-nav li a:hover {
margin-right: auto;
margin-left: auto;
background:#cccccc;
color:#000;
}
"Help me Obi Wan Kenobi your my only hope!"
Your first CSS selector is looking for a ul with a class of list-nav, not an id of list-nav. Change your first CSS rule to:
ul#list-nav {
padding: 0;
margin: 0;
list-style: none;
width: 525px;
margin: 0 auto;
}
And your navigation bar is magically centered. Please see this jsFiddle for a working demonstration > http://jsfiddle.net/TLaN5/. Obviously you'll need to amend the width of the parent ul in order to accomodate the correct width of the elements within, but you should get the idea.
I would wrap the entire page inside <div class="wrap">. You have declared margin twice in the code, so I would remove the first occurrence and leave it like:
ul#list-nav {
padding: 0;
list-style: none;
width: 725px; //NOTE I have increased the width value.
margin: 0 auto;
}
Also, find
ul {
display: inline;
text-decoration: none;
color: black;}
[around line 20] and remove display: inline; rule. This should fix your issues. Check the live example here.
You can give a define size to the ul and center its content (remove the display-inline, indeed)
ul {
width: 960px;
margin: 0 auto;
text-align: center;
}
Then display the child li elements as inline blocks :
ul li {
display: inline-block;
}
The inline-block property won't work in ie7, so check your browser targets first...
Another way is to just use the good ol'
ul li {
float: left;
}
ul:after {
display: block;
content: "";
clear: both;
}
But the li won't be centered within the ul and you'll have to use javascript if you absolutely want to do this dynamically (without assigning a fixed with to each li).
I have an image in a list item I need floated. Everything looks fine in FF/6+. Webkit and IE, however, show the list icon on top of the image. When I try floating the list item itself, the icon simply vanishes. Is there a CSS way around this issue? I tried wrapping the content in a span, and still no solution. I've removed some of the text in order to lighten the code here.
<ul class="leftList">
<ul>
<li>Pillow menu to customize your night's sleep</li>
<li>Complimentary bathroom amenities</li>
<li><span class="special_needs_list_item"><a rel="tooltip nofollow" title="Tooltip - Lorem ipsum"><img src="http://teamsite-prod.rccl.com:8030/DOT/img/global/special_needs.png" alt=""></a> Some srooms in this category are wheelchair-accessible.</span></li>
</ul>
</ul>
#ccStateroomFeatures ul {
float: left;
width: 320px;
margin-left: 15px;
font-size: 12px;
}
#ccStateroomFeatures ul li {
margin-bottom: 5px;
}
#ccStateroomFeatures .leftList {
width: 490px;
float: left;
}
#ccStateroomFeatures .leftList ul,
#ccStateroomFeatures .rightList ul {
float: none;
margin-left: 15px;
width: auto;
}
#ccStateroomFeatures .leftList ul .special_needs_list_item {
margin:0 0 20px -15px;
padding-left:15px;
}
#ccStateroomFeatures .leftList ul .special_needs_list_item img {
float:left;
margin:3px 5px 0 15px;
overflow:hidden;
width:13px;
}
I'm not sure I understand what you're trying to do. Are you trying to have the image supplied be used instead of the list icon?
If so, you'll want to use list-style-type:none to deal with that. Then play around with the margins to get it to line up like you want.