position close button inside a image - php

I'm trying to put an anchor in the top-right of an image.
This is my view:
<div class="table">
<tr>
<?php foreach ($q as $row)
{
$var = $row->path;
$info = pathinfo($var);
echo '<td><a href="#" style= "position:relative">
<img src="'.base_url().'images/thumbs/'.$info['basename'].'"/>
</a>'.anchor('gallery/remove_photo/'.$row->id,'<i class="icon-remove"></i>','class="close"').'</td>';
}?>
</tr>
</div>
I've tried by set the position relative and the postion of the anchor absolute but it now works. I forgot to say that i'm using bootstrap 3

Why not just use an image map?
http://www.w3schools.com/tags/tag_map.asp
<img src="planets.gif" width="145" height="126" alt="Planets" usemap="#planetmap">
<map name="planetmap">
<area shape="rect" coords="0,0,82,126" href="sun.htm" alt="Sun">
<area shape="circle" coords="90,58,3" href="mercur.htm" alt="Mercury">
<area shape="circle" coords="124,58,8" href="venus.htm" alt="Venus">
</map>
There are even some decent online tools to find the coordinates if needed like this one.
http://www.image-maps.com/

To position something absolutely (which is what you want to do), it has to have container that also has positioning set to position itself against. Sounds complex, but it's not really.
If you set your container to position:relative (meaning keep it in the flow of the document where it would normally be), then you can set descendant elements to position: absolute.
So, in your case, if you wrap your image and button in a div and set the div to position: relative, you can set the button to position: absolute like this:
<div style="position: relative;">
<img src="yourimagename.jpg" alt="">
<button style="position: absolute; top: 0; right: 0; z-index: 1;">&times</button>
</div

Related

IMG title edit using CSS but identifying by PHP call

I currently have an info image in a table.
When I hover over the icon it displays the artist description in the tool tip because i have it set up to do so.
<img src='images/info.png' width="20" height="20" title="<?php echo $artist['description']; ?>">
This is my CSS
img[title="<?php echo $artist['description']; ?>"]{
border-radius:50%;
background-color: red;}
It doesnt work. Is there anything I can do?

I want to give green and red color for image areas

I want to show status with 0 area as red dot and status with 1 area are green. I used style tag for area. But not color coming on image area. Anybody knows please help me. I am sharing my code below
<html>
<map name="map1" id="_map1">
<?php
foreach ($points as $point)
{
$name=$point->name;
$status=$point->status;
if($status==1){ ?>
<area shape="rect" coords="10,15,18,20" href="<?php echo base_url()?>assets/images/green.jpg" alt="" title="" onmouseover="<?php echo $name; ?>" />
<?php
}
else if($status==0) {?>
<area shape="rect" coords="0,0,50,50" href="<?php echo base_url()?>assets/images/red.jpg" alt="" title="" onmouseover="<?php echo $name; ?>"/>
<?php
}
} ?>
</map>
<img id="map1" src="<?php echo base_url()?>assets/images/rectangle.png" usemap="#map1" border="0" width="800" height="600" alt="" />
</html>
See the example use of <map> Html map tag
The href attribute does not show the image (red or green). It is a hyperlink to the target image. The image displays on the screen is the src file of the <img> tag.
You may need to generate the image dynamically on the server side, or use <canvas> to render the data on the client side.

Trying to align my embed photo gallery (coming from tinymce editor) at center of my modal div

Im using tinymce to insert news into a website.
I inserting a embed code that corresponds to a photo gallery in tinymce html editor. (Im using an online photo sharing service for my images gallery.)
This service give me a "embed code" and when I insert in my tinymce html editor I get this in my html: (my embed tag becomes a object tag)
<p>
<object style="height: 350px; width: 460px;" width="460" height="350"
align="middle"
data="http://flash.picturetrail.com/pflicks/3/spflick.swf"
type="application/x-shockwave-flash">
<param name="src" value="http://flash.picturetrail.com/pflicks/3/spflick.swf" />
<param name="quality" value="high" /><param name="flashvars" value="ql=2&
src1=http://pic20.picturetrail.com:80/VOL1566/13680586/flicks/1/9035174" />
<param name="wmode" value="transparent" /><param name="allowscriptaccess" value="sameDomain" />
</object>
</p>
And now Im trying to align my photo gallery at center of my modal div, but Im not having sucess doing this.
Because I also need to float:left my photo gallery because if my paragraph text is too small my photogallery is coming to stick my paragraph text and I dont want that.
I want always a margin-top of 20px below my news image with .img class.
Do you know how can I solve this?
This is my fiddle with full example: http://jsfiddle.net/65z7w3z3/
This is how I show my textarea content in website;
echo '<p>'.$result_read_textarea['content_textarea'].'</p>';
My Html:
<div class="modal">
<h2>Title of my first news</h2>
<span id="date">15/08/2014</span><br />
<img class="img" src=""/>
<p>my first paragraph</p>
<embed src="http://flash.picturetrail.com/pflicks/3/spflick.swf"
quality="high" FlashVars="ql=2&src1=http://pic20.picturetrail.com:80/VOL1566/13680586/flicks/1/9035174" wmode="transparent" bgcolor="" width="460" height="350" name="Acrobat Cube" align="middle" allowScriptAccess="sameDomain" style="height:350px;width:460px" type="application/x-shockwave-flash">
</embed>
<div id="pdfs">
<h3>Links:</h3>
<ul class="links">
<li> Link 1</li>
<li> Link 2</li>
<li> Link 3</li>
</ul>
</div>
<span class="close">Back</span>
</div>
This is because are floating the element. Remove the float. Also add a clear div to help with your layout too. The clear div will stop it floating up with your other elements.
DEMO http://jsfiddle.net/david321312312231/65z7w3z3/1/
CSS Update
.clearfix {
clear: both;
width: 100%;
display: block;
}
#pdfs, embed
{
margin:20px auto;
clear:both;
width:100%;
}
HTML Update
// html code
<div class="clearfix"></div>
<embed // more html code
You need to create a wrapper div around the embed tag and align that to center:
<div class="wrapper" style="width: 460px; margin: 0px auto;">...</div>
http://jsfiddle.net/65z7w3z3/2/
Create a tag around your Gallery then style it.
HTML Gallery Section:
<div class="photogallery">
<embed src="http://flash.picturetrail.com/pflicks/3/spflick.swf"
quality="high" FlashVars="ql=2&src1=http://pic20.picturetrail.com:80/VOL1566/13680586/flicks/1/9035174" wmode="transparent" bgcolor="" width="460" height="350" name="Acrobat Cube" align="middle" allowScriptAccess="sameDomain" style="height:350px;width:460px" type="application/x-shockwave-flash">
</embed>
</div>
CSS for Photo Gallery:
.photogallery {
width: 400px;
margin: auto;
}

Use Anchor title instead of image title

If I have an image in an anchor, how can I make the title of the anchor appear, and not that of the image element?
I know I could remove the title attribute with javascript, but I'm hoping there is a simpler solution.
For example
<a title="Anchor Title"><img title="Image Title" /></a>
If you hover over the link, it will display "Image Title".
What I've Tried
With CSS, I thought maybe I could change the z-indexes to push the anchor to the front, or maybe I could display the anchor as a block and give it the width and height of the image. This did not work. See JSFiddle here.
I was hoping to find a solution with CSS or maybe HTML.
The reason I want to do this is is that I'm working with Wordpress, spitting out posts and thumbnails. I want the thumbnails to link to a certain page, and I want to have a universal title for the link, but it is taking the title from the individual thumbnails. Here's the Wordpress/PHP code:
<a href="<?php the_permalink(); ?>" title="Click to see Featured Stories">
<?php the_post_thumbnail(); ?>
</a>
Pass an empty string in the title attribute in the $attr array in the thumbnail:
<?php the_post_thumbnail('thumbnail', array('title' => '')); ?>
This offers a general solution, disregarding WordPress. CSS prevents the title to show up.
HTML:
<a title="Anchor Title">
<img title="Image Title" src="http://codepen.io/images/logo.png" />
</a>
With CSS:
a {
display: inline-block;
}
img {
pointer-events: none;
}
Result
See CodePen example
Just put a transparent <span> over the image, with transparent background and desired title attribute.
Markup
<a href="#">
<img title="Image Title" />
<span title="Div Title"></span>
</a>​
CSS
img { width:50px;height:50px;background:blue; }
a, img { position:absolute; }
a { z-index:4;display:block;width:50px;height:50px; }
img { z-index:2; }
​span{
top:0;
left:0;
position:absolute;
width:50px;
height:50px;
display:block;
z-index:100;
background-color:transparent;
}​
I just forked your fiddle, works in Chrome at least.
I think removing the img title attribute is the simplest solution of all.
http://jsfiddle.net/hnmuj/
CSS:
#foo {
position:relative;
display:block;
}
#foo span {
position:absolute;
width:100%;
height:100%;
z-index:1;
top:0;
left:0;
display:block;
}
​
HTML:
<a title="Anchor Title" id="foo">
<span></span>
<img title="Image Title" />
</a>​

limit number of images in a row?

i have a set of images that i want to show where they are saved into my database as linked, where each images has its thumbs, now i have used limit inquery to show a small number of images where the user needs to go next to show the other, my question is that how can i arrange those images where 4 images in a row and 3 columns
HTML:
<div id="image_container">
<img src="" alt="" />
<img src="" alt="" />
<img src="" alt="" />
<img src="" alt="" />
...
</div>
CSS:
#image_container { width:440px; overflow:hidden; }
#image_container img { width:100px; margin:5px; float:left; display:inline; }
You may need to adjust the sizes; this is the general concept though.
If the images all have the same width then make the container only wide enough for 4 images and float the images left
Otherwise loop through the images and use the modulus operator to test for which image in the row you are on. If you are on an image that should be the first in the row you can clear the floats on that image.

Categories