I have a HTML structure like this:
<div id="main_tabs">
<ul id="main_tabs_nav">
<li class="sn1"><a id="divleftlink0" rel="nofollow" href="javascript:divActivate(0,2,'divleft');" class="active">Newsletter</a>
</li>
<li class="sn2"><a id="divleftlink1" rel="nofollow" href="javascript:divActivate(1,2,'divleft');" class="inactive">Get Social</a>
</li>
<li class="sn3"><a id="divleftlink2" rel="nofollow" href="javascript:divActivate(2,2,'divleft');" class="inactive">Testimonials</a>
</li>
</ul>
</div>
And I apply a CSS like this, and it works fine:
#main_tabs_nav li.sn1 a {
width: 107px;
background: transparent url("http://i.imgur.com/someimage.png") 0 0 no-repeat;
text-indent: -9999px;
}
But this does not work:
#main_tabs #main_tabs_nav li.sn1 a {
width: 107px;
background: transparent url("http://i.imgur.com/someimage.png") 0 0 no-repeat;
text-indent: -9999px;
}
How do I get the second piece of CSS code to work too ?
I want to put #main_tabs in the start of the CSS too, to strictly follow the hierarchy ..
There is nothing wrong with your HTML and CSS. Both of these CSS styles work from a hierarchical standpoint. You can see that I added in another style to turn the first link red using the #main_tabs as the parent, and it is working fine here.
If you are looking to do text replacement, I would use this method instead:
li.sn1 a {
text-indent: 100%;
white-space: no-wrap;
overflow: hidden;
}
Related
I have a cshtml page that has a list of images in DIV tags. It looks like this:
<div id="ActionButtonContainer" class="containerRight">
<div id="ActionButtonSidebar" class="sidebarRight">
<ul style="list-style-type:none">
<li title="Show More"><div class="icon lefticon" onclick="openNav()" /></li>
<li title="Edit"><div class="icon editicon" /></li>
<li title="Save"><div class="icon saveicon" /></li>
<li title="Cancel"><div class="icon cancelicon" /></li>
</ul>
</div>
</div>
When I run the above code, nothing shows up on the page. If change 1 of the elements to an image tag, all of a sudden all 4 items show up:
<div id="ActionButtonContainer" class="containerRight">
<div id="ActionButtonSidebar" class="sidebarRight">
<ul style="list-style-type:none">
<li title="Show More"><img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="icon lefticon" onclick="openNav()" /></li>
<li title="Edit"><div class="icon editicon" /></li>
<li title="Save"><div class="icon saveicon" /></li>
<li title="Cancel"><div class="icon cancelicon" /></li>
</ul>
</div>
</div>
The reason the src is that string, is that represents a blank 1kb image. If that's not there, Chrome will automatically put a border around the image for some stupid reason. I have tried src='', src='#', src='//:0', src='javascript:void(0)', they all end up showing a broken image on top of the image defined in the CSS class.
The reason I want the image source defined in the CSS file that when I change the src of the image tag to the actual image file, it refuses to size properly. I fought with it for an hour and I don't hate myself enough to continue down that road.
Any idea why none of the elements show when it's all DIV tags? Or how to remove the border around the image when no source is defined in Chrome in a more elegant less 'hacky' way?
Here's the CSS for reference:
.containerRight {
clear: both;
width: 80px;
margin: 0 auto;
float: right;
position: relative;
left: 90%;
}
.containerRight li {
padding-bottom:5px;
}
.containerRight button {
width: 100%;
}
.sidebarRight {
position: fixed; /* Stay in place */
z-index: 1; /* Stay on top */
top: 100px;
left: 93%;
overflow-x: hidden; /* Disable horizontal scroll */
padding-top: 60px; /* Place content 60px from the top */
transition: 0.5s; /* 0.5 second transition effect to slide in the sidebar2 */
float: right;
vertical-align: middle;
text-align: center;
}
.icon {
background-size: contain;
background-repeat: no-repeat;
height: 25px;
width: 100%;
cursor:pointer;
}
.editicon {
background-image: url("../../../Images/edit.png");
}
Remove border around the image: Should work with outline: none. Therefore it should be put to your .icon css class as far as I understood your issue.
.icon {
outline: none;
border: none;
background-size: contain;
background-repeat: no-repeat;
height: 25px;
width: 100%;
cursor:pointer;
}
However, you should generally try to provide a valid link with a img source that will be found and always include an alt-attribute on your image tag, so there will be an alternative text when the image couldn't be found.
I tried to reproduce your issue here. I can't see your local images of course, therefore it is all blank and I typed in ABC, so I don't really can reproduce your issue: https://codepen.io/alexiovay/pen/qBELZzy
i am currently having problem aligning facebook share button and tweet button with each other as i am weak in CSS.
here is my code:
<div class="fb-share-button" data-href="http://www.hootpile.com/<?php echo $username; ?>" data-layout="button"></div>
Tweet <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script>
But they don't seem to align themselves with each other.
Your problems is linked to the structure.
One is a DIV and the other a A link.
You shall place both of then into a li list
See exemple bellow, just adapt the img uri & destination linked
.social-icon-fb {
background: url('../images/social-icon-fb.png') no-repeat;
width: 42px;
height: 42px;
display: block;
}
.social-icon-twitter {
background: url('../images/social-icon-twitter.png') no-repeat;
width: 42px;
height: 42px;
display: block;
}
<ul class="list-inline">
<li>
<a href="https://www.facebook.com/">
<span class="social-icon-fb"></span>
</a>
</li>
<li>
<a href="https://www.twitter.com/">
<span class="social-icon-twitter"></span>
</a>
</li>
</ul>
Adding the following CSS class to your page should work. If you're placing the two buttons side-by side in a containing div.
.fb_iframe_widget {
vertical-align: top;
}
Have you tried applying the style
display: inline-block;
If you apply the css to both class for the buttons then you should be able to get them to align..
please take a look at my jsfiddle for a css solution
https://jsfiddle.net/digitaliss/koo6o16n/
I'm running into a weird glitch which only seems to happen in chrome and safari. It's hard to explain why this happens with sample code, but I'll try to illustrate what I'm doing with code, while providing a link to the actual page below.
First of all, I have an unordered list displayed inline-block, so it can be justified just like text. Each list item contains an svg in an image tag and a paragraph with a short description, both wrapped in a single anchor tag. Nothing special i guess, but here's the catch: in chrome and safari the browser renders a 1px by approximately 15px blue/blackish line between the paragraph and the image, and I have no idea why this is happening. Here's the code:
<div class="wrapper">
<div class="justified-list home-icons">
<ul>
<li>
<a href="#">
<img src="http://voctel.wearebold.nl/wp-content/uploads/2015/02/company-building.svg" />
<br/>
<p>Description</p>
</a>
</li>
<li>
<a href="#">
<img src="http://voctel.wearebold.nl/wp-content/uploads/2015/02/company-building.svg" />
<br/>
<p>Description</p>
</a>
</li>
<li>
<a href="#">
<img src="http://voctel.wearebold.nl/wp-content/uploads/2015/02/company-building.svg" />
<br/>
<p>Description</p>
</a>
</li>
</ul>
<span class="stretcher"></span>
</div><!-- .justified-list -->
</div><!-- .wrapper -->
and here is the css (I'm using scss):
.wrapper {
width: 100%;
}
.justified-list {
width: 100%;
text-align: justify;
* {
display: inline;
}
li {
display: inline-block;
vertical-align: top;
}
.stretcher {
display: inline-block;
position: relative;
width: 100%;
height: 0;
}
}
Also, a codepen is provided here:
http://codepen.io/smelly586/pen/NPVVYd
If anyone has a clue on what's going on, or even better: has a possible fix for this, you have my gratitude.
Set your font-size on the element to 0. What you're seeing is the underline in the anchor element for whitespace in your HTML.
You could turn off the text-decoration: underline; that the browser renders by default for anchors, but let's assume that's not what you want to do.
Instead, the element with text will need to be reset to document root font-size (or whatever you want) using something like p { font-size: 1rem; }.
Example Codepen
So, accordingly, the SCSS/LESS would be:
.justified-list {
width: 100%;
text-align: justify;
* {
display: inline;
}
li {
display: inline-block;
vertical-align: top;
a {
font-size: 0;
p { font-size: 1rem; }
}
}
.stretcher {
display: inline-block;
position: relative;
width: 100%;
height: 0;
}
}
This is my jsfiddle
Here is the signup code, the code can be fully viewed in the jsfiddle
<li class="footer_row" align="center"><a href="" class="tsc_buttons2 grey" >sign up!</a></li>
All the Signup options is left aligned, in mozilla firefox , but it is perfect in the chrome browser in other few browsers, i just want to make it aligned centre in all the browsers, how can i make it ??
Please give text-align:center in your div.tsc_pricingtable03 li.footer_row class.
div.tsc_pricingtable03 li.footer_row {
background-color: #E2E2E2;
border-bottom: 1px solid #CCCCCC;
float: left;
height: 40px;
padding-bottom: 6px !important;
padding-top: 14px !important;
text-align: center /*changes here*/;
width: 100%;
}
you mixed the class name with attributes, should be:
<li class="footer_row align_center"><a href="" class="tsc_buttons2 grey" >sign up!</a></li>
try this.
<li style="text-align:center" class="footer_row"><a class="tsc_buttons2 grey" href="">sign up!</a></li>
Use position as absolute , and left alignment as 30 % , it is followed below,
.tsc_buttons2.grey {
position: absolute;
left: 30%;
Use style="text-align:center" inside the List Tag
I want to cast additional shadows with pseudo-elements ::after and ::before to create sort of a page curl effect. But whenever an <img> is involved its src keeps overlaying the shadow. Is that a general limitation or is there a workaround?
<ul>
<li class="imgContainer"><img class="imgFake" /><br><span class="imageTag">some Title</span></li>
<li class="imgContainer"><img class="imgFake" src="http://wallpaperstock.net/maggie-grace-portrait_wallpapers_14105_1600x1200.jpg"/><br><span class="imageTag">some Title</span></li>
<li class="imgContainer" style="margin-bottom:50px;"><img class="imgFake" src="http://wallpaperstock.net/maggie-grace-portrait_wallpapers_14105_1600x1200.jpg"/><br><span class="imageTag" style="top:auto; bottom:27px;">some Title</span></li>
</ul>
http://jsfiddle.net/BpgXC/7/
Please, take a look: http://jsfiddle.net/BpgXC/12/
I've changed img.imgFake z-index:
img.imgFake {
position: relative;
display: block;
width: 400px;
height: 250px;
background: rgba(135,195,235,.5);
padding: 5px;
font: 12px/12px sans-serif;
z-index: -2;
}