Not sure why, but none links over the images in my posts works unless it's set to position: absolute;
Summary:
No problems with neither src or href
The pointer cursor does not appear
Nothing happens when clicking on the image
The links works when I set a to position: absolute;, but then everything is misplaced and so on.
I have tried shortening it up to make it easier to debug.
Shorten HTML
<a href="#.jpg">
<img src="#.jpg" alt="Alt text" width="1200" height="800">
</a>
(Shortened) Complete HTML
<div class="clearfix"></div>
<div class="holder blacktext bildeserieholder">
<div class="container">
<div class="row">
<div class="col-md-12 centertext">
<img class="aligncenter size-full wp-image-512" src="#.jpg" alt="text" width="1200" height="800" />
<img class="aligncenter size-full wp-image-513" src="#.jpg" alt="text" width="600" height="900" />
<img class="aligncenter size-full wp-image-514" src="#.jpg" alt="text" width="1200" height="800" />
<img class="aligncenter size-full wp-image-515" src="#.jpg" alt="text" width="1200" height="800" />
<img class="aligncenter size-full wp-image-516" src="#.jpg" alt="text" width="600" height="900" />
</div>
</div>
</div>
</div>
</div>
I have tried:
Using cursor: pointer to the link attribute.
Removing all img classes
Removing all CSS on both images and links in Chrome Inspect Element
It's hard to find out where I have done something wrong, so I would really recommend checking out the page: http://goo.gl/DqXAlC
Maybe not relevant, but I will add this information anyways regarding what I am using:
Wordpress
Bootstrap
Types (custom posts etc plugin)
The images are being uploaded with Types within each posts in a WYSIWYG editor called "bildeserie". In my single PHP I have the following which echos the images:
<?php echo(types_render_field( "bildeserie", array( 'raw' => true) )); ?>
Do you have a working solution or any ideas?
Note: The problem is with the images below the header and all the text.
Solutions:
.holder img {
pointer-events: none;
}
The above is disabling the link on the image, commenting it out will make everything work.
Second solution:
a {
display:inline-block;
}
That also fixes your problem (by expanding the link to the dimensions of the image).
I would imagine that the img has a size and the link does not have a size unless set to absolute. If the a doesn't have a size, you aren't clicking on the a you are clicking on the img, give the a a size and see what happens
You should disable this line in your style.css file:
.holder img {
pointer-events: none;
}
Related
My code currently looks a bit like this:
<marquee>
<img src="https://cdn140.picsart.com/274296681002211.png" alt="Mushroom" width="100" height="100">
</marquee>
I am a rookie and have tried using the style="" code but it seems to just break everything.
Put a div around your image than you can adjust the position easily with css. Check this link for further instructions: https://www.w3schools.com/css/css_positioning.asp
HTML
<div class="image">
<marquee>
<img src="https://cdn140.picsart.com/274296681002211.png" alt="Mushroom" width="100" height="100">
</marquee>
</div>
CSS
.image{
position: absolute;
}
As an alternative you can use inline style with the style="" propertie.
<div style="position:absolute">
On a website I am building, the onmouseover/out feature is working, however the initial image that is meant to be there won't load and will instead show a blank image link like it's trying to find it. When I do mouseover, the pictures load and are fine from then on.
I've tried changing the image it tries to load initially (which is definitely in the right place as it's one of the onmouseover/out pictures that functions correctly), but it still won't load.
<header class="masthead text-center">
<div style="width:1px; height:1px; visibility:hidden; overflow:hidden">
<img class='img-responsive center-block' src="/images/people/MinION" width="500">
<a href="https://team-schwessinger.github.io/Team_B_S/" />
</div>
<img class='img-reponsive center-block' img src="images/people/MionION.png" width="500" alt="Leaf" onmouseover="this.src='images/people/Leaf.jpg';" width="500" onmouseout="this.src='images/people/MinION.jpg';" width="500" /></a>
I believe I am having an issue with
<img class='img-responsive center-block' src="/images/people/MinION" width="500">
which is meant to be there when the website loads, before any mousing occurs. The website recognises it is trying to find a picture, but can't. I am confused about this as it is able to find and use that MinION picture in the actual mouseover function.
Any help in understanding why this is happening is greatly appreciated, thank you!
Change your syntax as below, I have changed image links for me to work but you can use your relative paths.
<header class="masthead text-center">
<div style="width:1px; height:1px; visibility:hidden; overflow:hidden">
<a href="https://team-schwessinger.github.io/Team_B_S/" />
<img class='img-responsive center-block'
src="https://timedotcom.files.wordpress.com/2015/09/googles-new-logo-
5078286822539264-2-hp.gif" width="500">
</div>
<a href="https://team-schwessinger.github.io/Team_B_S/">
<img class='img-reponsive center-block' img
src="https://timedotcom.files.wordpress.com/2015/09/googles-new-logo-
5078286822539264-2-hp.gif" width="500" alt="Leaf"
onmouseover="this.src='http://www.google.com/logos/doodles/2016/st-
patricks-day-2016-4834639321497600-hp2x.gif';" width="500"
onmouseout="this.src='https://timedotcom.files.wordpress.com/2015/09/googles-new-logo-5078286822539264-2-hp.gif';" width="500" />
</a>
refer to jsFiddle
How do you remove unneeded space around images in HTML?
One of my images is coming to far away from the text, and it is messing up the look of the website. There is nothing wrong with the CSS I am using, but I believe because that there is too many HTML tags around it, it has a large space.
Please limit solutions to basic CSS and HTML, as per I can properly understand how it works.
EDIT: I am sorry, I was a bit vague about what my challenge was. I am using the Bootstrap Library, and have been looking a this following template:
http://www.markups.io/preview/varsity/
I really like the template, and I am occasionally taking code snippets out of it. I used the top bar, and replaced their logo with a different image. The image looks fine on desktop, but when a go on my mobile phone, it comes out what too low covering some important content. Anything you guys can do?
EDIT 2:
I have attached two photos of the look and what the problem looks like. The first one is the Desktop view (which is great), and the second one is the mobile view (which is too low). I don't have any more information... from the original post to EDIT 1, EDIT 2, that is all the info that I have.
Remove the spaces and line breaks between images:
<img src="http://placehold.it/20x20" /> <img src="http://placehold.it/20x20" />
<img src="http://placehold.it/20x20" />
to:
<img src="http://placehold.it/20x20" /><img src="http://placehold.it/20x20" /><img src="http://placehold.it/20x20" />
Put this in your css file:
img {
margin: 0;
}
or use this in-line style in your html file:
<style type="text/css">
img {
margin: 0;
}
</style>
You can use the letter-spacing propriety of CSS
img {
letter-spacing: -2px;
}
I think you should remove space between your code!
so you must change this code
<img src="1.jpg" />
<img src="2.jpg" />
<img src="3.jpg" />
to this code (add comment code)
<img src="1.jpg" /><!--
--><img src="2.jpg" /><!--
--><img src="3.jpg" />
or to this code (literally remove space)
<img src="1.jpg" /><img src="2.jpg" /><img src="3.jpg" />
Since the template uses twitter bootstrap,
try adding img-responsive class to your image
Example, from:
<img src="1.jpg" />
to
<img class="img-responsive" src="1.jpg" />
Dear Members of this amazing Forum
I recently started using Html again and for the love of God i can't figure out where the problem is.
I created 3 Div's, each with 1 image, 1 group of images, and 1 image again. (same problem if all are in the same div, with a rather basic Css)
.HeaderNav {
margin: 0;
padding: 0;
overflow: auto;
opacity: 1;
overflow-x: hidden;
overflow-y: hidden;
display: block;
}
And the Html to use it.
<div class="HeaderNav">
<img src="../Images/shang3_03.jpg" alt="" width="940" height="120" class="HeaderNav" />
</div>
<div class="HeaderNav">
<img src="../Images/shang3_05.jpg" alt="" width="240" height="55" />
<img src="../Images/shang3_06.jpg" alt="" width="66" height="55" />
<img src="../Images/shang3_07.jpg" alt="" width="84" height="55" />
<img src="../Images/shang3_08.jpg" alt="" width="72" height="55" />
<img src="../Images/shang3_09.jpg" alt="" width="74" height="55" />
<img src="../Images/shang3_10.jpg" alt="" width="107" height="55" />
<img src="../Images/shang3_11.jpg" alt="" width="62" height="55" />
<img src="../Images/shang3_12.jpg" alt="" width="70" height="55" />
<img src="../Images/shang3_13.jpg" alt="" width="165" height="55" />
</div>
<div class="HeaderNav">
<img src="../Images/shang3_14.jpg" alt="" width="940" height="133" />
<br/>
</div>
What results in the image below, sadly i don't get where the little space is from. Or why it's not on top too. Somehow i'm really confused where this issue is from and i'd realy appreciate the help.
[2]: http://i.imgur.com/SIkB7Hs.png <-- this one schould be a bit more clear sorry about that
edit: if found a rather face-> wall way to fix it with margin-top. And just making a div class for everyline. What's probably not the best way to go.
Ok, a few things here.
For one, with questions like this, it helps people answering a LOT if you post your code in a JSFiddle, like this here (though the images don't show there because they're relative URLs).
Also, it seems if you float the images to the left you can get rid of the spacing:
.HeaderNav img {
float: left;
}
Just to note, I have no idea why the spacing existed in the first place. Another tip: you should use 'Inspect Element' in Chrome or Firebug in Firefox to take a look at elements and see padding, margins, etc. Usually that makes it obvious where whitespace is coming from, though in this case I found nothing. Floating to the left was just an idea that seemed to work.
Probably because your <img> are still being declared as inline-level elements. Use:
.HeaderNav img {
display: block;
}
Also, you should check if a margin or padding have been assigned to the image element. If you do, reset them.
Also, make sure your padding and margin are 0 for the html and body...
so, try this:
body, html {
margin: 0;
padding: 0;
}
HTML cannot be used on it's own; it has to have CSS working with it continuously.
A bit confusing question, I don't understand it all. But check this jsFiddle. Is this what you mean?
Also remove the HeaderNav class from the first image.
<div class="HeaderNav">
<img src="../Images/shang3_03.jpg" alt="" width="940" height="120" />
</div>
The img element default display type like inline-block, because of the font-size, so the img element maybe have 3px space.
To solve this problem, you can use the code below:
.HeaderNav img {
display: block;
}
or
.HeaderNav img {
float: left;
}
They all will change the img elements display type, I recommend the first one.
I have - img id="logo" SO I can have my logo on my website, the full code for it being:
<img id="logo" src="nsc/logo2.png" alt="logo" />
How can I link this logo image using <a href=""> ???
I've tried many different ways but they don't work :/
<img id="logo" src="nsc/logo2.png" alt="logo" />
It would be nice to embed in a link tag. :)
<a href="your.html">
<img id="logo" src="nsc/logo2.png" alt="BrandLog" />
</a>
it's clean and no need of javascript :)
It's super simple, just wrap the <img> tag with an anchor tag <a>:
<a href="myUrl.html">
<img id="logo" src="nsc/logo2.png" alt="logo" />
</a>
This will turn the entire image into a link for you :)
For people who want to receive click event on a tag instead of img tag
<a href="/chat" style="background: red; display: inline-block;">
<img src="chat.svg" style="pointer-events: none; display: block;" width=40 height=40>
</a>
On a tag
display: inline-block in a: allows to set a width and height on a tag
On img tag
display: block: help remove extra space below the image
pointer-events: none: ignore click on img, click event will fired on a tag
If you can't wrap the image in a link, an image map should work just as well without requiring JavaScript & without needing to wrap the element.
I add id in img tag like this:
<img id={logo.id} src={logo.url} onError={this.handleImageError} />
Since I am working on React that's why I used JSX in the id and src attribute. onError attribute is used if the image is broken. It gives me an event, So this is how I access the id attribute:
handleImageError = (e) => { console.log(e.target.id) }
Here is the solution for you,
<img id="logo" src="nsc/logo2.png" alt="logo" onClick="window.open('http://yahoo.com');" />