I have an html portion of code in my page that goes something like this:
<section class ="sidebar">
<ul>
<li class="facebook">Facebook</li>
<li class="linkedin">LinkedIn</li>
<li class="twitter">Twitter</li>
<li class="google-plus">Google+</li>
</ul>
</section>
And the css goes like this:
.sidebar ul {
float: left;
}
.sidebar ul li{
display: block;
width:35px;
text-indent: -9999px;
margin: 3px;
}
li.facebook{
height: 35px;
background: url(img/icon_face.png) center center no-repeat;
background-size: contain;
}
li.twitter{
height: 35px;
background: url(img/icon_twitter.png) center center no-repeat;
background-size: contain;
}
li.google-plus{
height: 35px;
background: url(img/icon_g+.png) center center no-repeat;
background-size: contain;
}
li.linkedin{
height: 35px;
background: url(img/icon_in.png) center center no-repeat;
background-size: contain;
}
What happens here is that I have 2 strange issues:
First the element li.google-plus does not show in any of the browsers. The browsers just ignore it. Here is what firebug shows:
The second is that the only image that shows in firefox is the twitter one. In chrome and opera all the other ones show correctly. As they are showing correctly in other browsers I assume the problem is not the path in the background property.
Any idea on what the problem may be?
EDIT:
Check what firebug says about the background image path:
It says that it couldn't load the given url.
Both in .sidebar ul li and in li.facebook,li.twitter etc. You should write width: and height: properties which You didn't set.
Ok, so it turns out that the problem was my AdBlock extension. After disabling it, it started working normally.
Figured it out through this answer: https://stackoverflow.com/a/466020/1235708
Related
I am making an html website and trying to make the website so when you click the image it takes you to another website. This is the code I have in index.html
<a href="https://www.youtube.com/">
<div class="metFinLogo"></div>
</a>
and in css
.metFinLogo{
background-image: url('./images/metFinLogoImg.png');
background-size:contain;
width: 250px;
height:200px;
margin: 5%;
background-repeat: no-repeat;
}
When I open index.html the image can still be selected even outside image. I need help to make it so that only clicking where there is image sends to link.
The <div> tag is a block level element. It will work if you add display: inline-block to .metFinLogo
.metFinLogo{
background-image: url('./images/metFinLogoImg.png');
background-size:contain;
width: 250px;
height:200px;
margin: 5%;
background-repeat: no-repeat;
display: inline-block;
}
inline-block It’s formatted just like the inline element, where it doesn’t start on a new line. BUT, you can set width and height values.
.metFinLogo{
display:inline-block;
}
.metFinLogo{
background-image: url('https://static.remove.bg/remove-bg-web/6cc620ebfb5922c21227f533a09d892abd65defa/assets/start_remove-c851bdf8d3127a24e2d137a55b1b427378cd17385b01aec6e59d5d4b5f39d2ec.png');
background-size:contain;
width: 250px;
height:200px;
margin: 5%;
background-repeat: no-repeat;
display: inline-block;
}
<a href="https://www.youtube.com/">
<div class="metFinLogo"></div>
</a>
This question already has an answer here:
How to have both position fixed and background-attachment fixed?
(1 answer)
Closed 2 years ago.
I have a parent div which is holding links called #linkHolder. I have its position:fixed. The links have a background which have a background-attachment: fixed to give it that nice background effect. Those two things seem to cancel each other out. Is there a way around this issue?
#linkHolder {
display: block;
position: fixed;
top: 0;
width: 100%;
}
ul {
list-style-type: none;
overflow: hidden;
background-color: #1b242f;
text-align: right;
font-size: 22px;
width: 100%;
font-family: "Sansita Swashed";
}
ul li {
display: inline-block;
padding-right: 6%;
}
#homeLink {
background-image: url("/static/portfolioBackground/linkBackA.png");
background-repeat: no-repeat;
background-size: cover;
background-position: center;
background-attachment: fixed;
}
<div id="linkHolder">
<ul>
<li><a id="homeLink" href="/">Home</a></li>
<li><a id="aboutLink" href="/about">About</a></li>
<li><a id="serviceLink" href="service">Services</a></li>
</ul>
</div>
Here's the issue on codepen I am having.
https://codepen.io/webdev154676/pen/VwjNoRN
Here's what I would like to have with the background image, but with the #linkHolder as position fixed, it will not work. Please help, and thank you for your time.
https://codepen.io/webdev154676/pen/rNLgBVv
From your question I'm understanding that the issue is that the background image is a little more blurred than what you would like to have.
For that i sudjest you to try using the background-size attribute and play around with it giving some sizes in % like
#homeLink{
background-size:90% 100%;
}
I have a PHPBB theme I am starting to construct. In the CSS file, I have three items--a body and two divs--with background images. The background images for the divs have ceased working in all browsers.
The site with the theme presented is here: https://www.tarazedi.com/index.php?style=7
The problem images are here: https://www.tarazedi.com/styles/wTcFresh/theme/images/site_banner.png
The CSS is located in wTcFresh/theme/.
The images are all in the same locations but there seems to be a pathing issue but is working very strangely. I have tried using both relative and absolute URLs. I have tried url(x);, url('x');, and url("x"); and also changing the other background elements. In no case have the banner and logo images started working, but the body image works fine despite being in the same place and using the same syntax. When I inspect the computed styles of the divs in Chrome the image will show as the full absolute URL correctly but the relative link links instead to tarazedi.com/images/site_banner.png which returns a 500 error because that URL is, obviously, useless. In Edge and Firefox the inspector shows the correct link to the image but still does not render.
I have cleared browser and site-side caches with each attempt I make to fix it.
I am baffled. What am I missing?
body {
color: #CCCCCC;
background-color: #000000;
background-image: url("images/bg.jpg");
background-attachment: fixed;
}
.headerbanner {
border: #009900 solid 4px;
border-radius: 40px;
background-image: url("images/site_banner.png");
background-attachment: fixed;
background-position: right;
background-repeat: no-repeat;
margin-left: auto;
margin-right: auto;
vertical-align: middle;
}
.headerlogo {
border: #003300 solid 4px;
border-radius: 36px;
overflow: hidden;
background-repeat: no-repeat;
background-image: url("images/site_logo.png");
background-attachment: fixed;
background-position: left center;
vertical-align: middle;
}
To achieve expected result,adjust background-position and it is not issue with the background-image
1.Remove background:position to see the difference
Editing it thusly fixed the problem and it now renders correctly. Thank you very much!
.headerbanner {
border: #009900 solid 4px;
border-radius: 40px;
background-image: url("images/site_banner.png");
background-position: right;
background-repeat: no-repeat;
margin-left: auto;
margin-right: auto;
align-items: center;
}
.headerlogo {
border: #003300 solid 4px;
border-radius: 36px;
background-image: url("images/site_logo.png");
overflow: hidden;
background-repeat: no-repeat;
background-position: left;
align-items: center;
}
I am new to css and the image for my header is not displaying. Whenever I try to add it to my header the nav gets a slightly darker tint of red? You and your genius minds figure it out!
css:
header {
background: url("http://www.charlottecentercity.org/wp-content/uploads/2013/09/Imaginon-pic.jpg");
background-size: cover;
image-repeat: no-repeat;
}
ul {
list-style-type: none;
margin: 0;
padding: 0;
vertical-align: middle;
line-height: 70px;
display: inline;
}
li {
display: inline;
}
nav {
background: rgba(255,0,0,0.5);
}
nav img {
height: 60px;
margin: 5px;
float: left;
}
html:
<header>
<nav>
<img src="https://dl.dropboxusercontent.com/u/105222237/RGBjpeg.png" />
<ul>
<li>About Imaginon</li>
<li>General Info</li>
<li>Programs and Events</li>
<li>Plan Your Visit</li>
<li>Just for Fun</li>
</ul>
</nav>
</header>
The background image is showing on the header, but:
it is set to background-size: cover, which means that you only see the very top, blue part. Presumably, when you have more content, you'll see more of the header, but in the mean time you could add a min-height: 600px; for example.
the nav has a reddish, semi-transparent background color that sits on top of the header background color. Just remove that red color if you don't want it.
Try and give the header (min/max) width / height
Add css overflow:hidden to your header.. and do the same
in future to all your wrapper elements.
Do give the header a defined size, as it will not be able to fill something that does not have a defined size to it.
header {
margin: 0;
padding: 0;
width: 100%;
height: 100px;
background: url(../wp-content/uploads/2013/09/Imaginon-pic.jpg) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
If your style sheet is in a subfolder like I usually have, make sure to add ".." to your image location to tell css to step back one directory. Using a direct path will require another http request, not a huge deal but slows your site down in the long run.
I included the webkit background code because I believe it to be easier to use. As well as creating browser compatibility.
I've managed to get my header to work as a link in ff, safari and opera with the css image replacement
#header h1 {
background-image: url(../images/logo.png);
background-repeat: no-repeat;
text-indent: -9999px;
margin-left: 15px;
}
#header h1 a {
display: block;
height: 120px;
width: 400px;
margin-top: -135px;
}
I'm trying to optimize the site its for in IE, my last step before I launch it on monday but the logo doesn't appear at all in IE 8 or 9, But it very surprisingly does in IE 7. I managed to get the logo to appear in IE9 by making the display inline-block
.ie9 #header h1 {
background-image: url(../images/logo.png);
background-repeat: no-repeat;
text-indent: -9999px;
margin-left: 15px;
}
.ie9 #header h1 a {
display: inline-block;
height: 120px;
width: 400px;
margin-top: -135px;
}
bit the image is no longer a link when I do this, does anyone have any idea how to fix this? I would put the image in the HTML instead of using the image replacement but Its been hammered into my head that from an SEO standpoint using the image replacement is better.
I think it is the margin-top: -135px causing the problem. The height is only 120px so it will end up being -15px (height - margin) so disappearing underneath the bottom of the H1 tag.