so I am pretty much making a table with images that when you hover over show color. Right now it's pretty much just very simple, but I was wondering how I could add a border to do the table, and maybe a grey background?
My HTML:
<table>
<tbody>
<tr>
<td><a href="http://online.wsj.com/news/articles/SB10001424052702304626804579361520890893170" target="_blank">
<img class="homepghovr" src="https://www.realtyshares.com/Media/Default/Content%20Images/AsSeenOn/wsj1.png" alt="" />
</a></td>
<td><a href="http://www.forbes.com/sites/rodebrahimi/2013/12/12/how-crowdfunding-will-impact-real-estate-investing-an-interview-with-realtyshares/" target="_blank">
<img class="homepghovr" src="https://www.realtyshares.com/Media/Default/Content%20Images/AsSeenOn/forbes1-1.png" alt="" />
</a></td>
<td><a href="http://money.cnn.com/news/newsfeeds/gigaom/articles/2014_02_04_finally_you_can_do_something_useful_with_bitcoin_invest_in_real_estate.html" target="_blank">
<img class="homepghovr" src="https://www.realtyshares.com/Media/Default/Content%20Images/AsSeenOn/cnnmoney1.png" alt="" />
</a></td>
<td><a href="http://www.bizjournals.com/sanfrancisco/print-edition/2013/08/09/rebooting-real-estate.html?page=all" target="_blank">
<img class="homepghovr" src="https://www.realtyshares.com/Media/Default/Content%20Images/AsSeenOn/business_times1.png" alt="" />
</a></td>
<td><a href="http://www.inman.com/2013/11/13/realtyshares-real-estate-crowdfunder-launches-first-equity-deal/" target="_blank">
<img class="homepghovr" src="https://www.realtyshares.com/Media/Default/Content%20Images/AsSeenOn/inman1.png" alt="" />
</a></td>
<td><a href="http://www.investorsbeat.com/all-in-one-investing-made-easy-with-realtyshares/" target="_blank">
<img class="homepghovr" src="https://www.realtyshares.com/Media/Default/Content%20Images/AsSeenOn/investorsbeat1.png" alt="" />
</a></td>
</tr>
</tbody>
</table>
My CSS:
IMG.homepghovr
{
opacity: 0.4;
filter: alpha(opacity=40); /* For IE8 and earlier */
}
IMG.homepghovr:hover
{
opacity: 1.0;
filter: alpha(opacity=100); /* For IE8 and earlier */
}
Fiddle: http://jsfiddle.net/v2JA9/
I was also told that I shouldn't be using a table for something like this, but rather be using div's, and ul's? Is that true? If so can someone point me to the right direction to utilize those tags?
Thank you very much!
If you just need a border to the table or container and grey colored background,just add this to your css,
table{
border:1px solid #000;
background-color:#eee;
}
if you need border for each item then just use
table,tr,td{
border:1px solid #000;
background-color:#eee;
border-collapse: collapse;
}
Demo here
if you need to use divs like a table
then
use
the parent container(or div) as display:table in css
and inner divs as display:table-cell
I'll answer that by telling you to not use a table. Obsolete for this kind of stuff, really.
Change < td> to < li>, remove < tr>, < tbody>, < table>, you need just one tag around li elements: < ul>. And check this out:
http://jsfiddle.net/v2JA9/3/
li {
float: left;
list-style: none;
}
ul {
background: #ccc;
border: 2px solid black;
padding: 0;
}
ul:after {
clear: both;
content: "";
display: block;
}
Basically, let's float (google: "floats css") them. ul:after being there as clearfix (google that as well), so it's as big as floating elements inside of it.
http://jsfiddle.net/v2JA9/6/
li {
display: inline-block;
list-style: none;
}
ul {
background: #ccc;
border: 2px solid black;
padding: 0;
}
Make li inline instead, so many of them don't mind standing in one line. Here: "display: inline-block", "inline" will work as well, but is less flexible. On the flipside, older browsers (IE...) can have some problems with inline-block. Up to you.
EDIT:
Someone mentioned it, let's work with it. Making ul behave like a table, with css.
http://jsfiddle.net/v2JA9/7/
Basically: "display: table;" on < ul> (container) + "display: table-cell;" on < li> (actual list elements, err, table cells...).
Solving your question (by keeping the tables) is super basic: JSFiddle
table, tr, td {
border: 1px solid black;
background-color: #e6e6e6;
border-collapse: collapse;
}
Using DIVs is definetely the best approach for building your site in a way that will allow you to leverage current and future web technologies: JSFiddle
I used display: inline-block;, but you could accomplish similar layout with display: block; and float: left;
div {
display: inline-block;
border: 1px solid black;
background-color: #e6e6e6;
}
Hope this helps get you started.
Yes, this can be done with list items as well - this is preferable because you have more options
<ul>
<li>
<a href="http://online.wsj.com/news/articles/SB10001424052702304626804579361520890893170" target="_blank">
<img class="homepghovr" src="https://www.realtyshares.com/Media/Default/Content%20Images/AsSeenOn/wsj1.png" alt="" />
</a>
</li>
<li>
<a href="http://www.forbes.com/sites/rodebrahimi/2013/12/12/how-crowdfunding-will-impact-real-estate-investing-an-interview-with-realtyshares/" target="_blank">
<img class="homepghovr" src="https://www.realtyshares.com/Media/Default/Content%20Images/AsSeenOn/forbes1-1.png" alt="" />
</a>
</li>
<li>
<a href="http://money.cnn.com/news/newsfeeds/gigaom/articles/2014_02_04_finally_you_can_do_something_useful_with_bitcoin_invest_in_real_estate.html" target="_blank">
<img class="homepghovr" src="https://www.realtyshares.com/Media/Default/Content%20Images/AsSeenOn/cnnmoney1.png" alt="" />
</a>
</li>
<li>
<a href="http://www.bizjournals.com/sanfrancisco/print-edition/2013/08/09/rebooting-real-estate.html?page=all" target="_blank">
<img class="homepghovr" src="https://www.realtyshares.com/Media/Default/Content%20Images/AsSeenOn/business_times1.png" alt="" />
</a>
</li>
<li>
<a href="http://www.inman.com/2013/11/13/realtyshares-real-estate-crowdfunder-launches-first-equity-deal/" target="_blank">
<img class="homepghovr" src="https://www.realtyshares.com/Media/Default/Content%20Images/AsSeenOn/inman1.png" alt="" />
</a>
</li>
<li>
<a href="http://www.investorsbeat.com/all-in-one-investing-made-easy-with-realtyshares/" target="_blank">
<img class="homepghovr" src="https://www.realtyshares.com/Media/Default/Content%20Images/AsSeenOn/investorsbeat1.png" alt="" />
</a>
</li>
The CSS for the list could look like this
IMG.homepghovr
{
opacity: 0.4;
filter: alpha(opacity=40); /* For IE8 and earlier */
}
IMG.homepghovr:hover
{
opacity: 1.0;
filter: alpha(opacity=100); /* For IE8 and earlier */
}
li{
list-style:none;
float:left;
border: 1px dashed black;
background-color: lightgrey;
}
The CSS for ur Table would look like this:
table{
border: 1px dashed black;
background-color: lightgrey;
}
You can use this code for better output
table{
border: 1px solid gray;
border-spacing: 0;
border-collapse: collapse;
}
table td{
border-left: 1px solid gray
}
table td:first-child{
border: none;
}
Check this Demo
For a border, add this:
<table border="1">
...
</table>
A ul is an unordered list. See an example here.
A div "divides" a webpage into a section. See here.
EDIT
Based on what it looks like you're trying to do, I wouldn't recommend a ul because then you'd get bullet points next to each icon.
Related
When I list a set of links, they go left to right on my web page. I want them to be stacked instead, so going from top to bottom. What do I need to add to do that?
Here is my HTML:
<div id="Links" style="width:650px; background-color: #dcdcdc; border: #00008b 2px dashed;">
Index Page
Schedule Page
To Top
</div>
Add this style to the links it will take the full width vertically.
style="display :block;"
<div id="Links" style="width:650px; background-color: #dcdcdc; border: #00008b 2px dashed;">
Index Page
<a href="pagetwo.html" style="display:block" >Schedule Page</a>
<a href="pagethree.html" style="display:block" >To Top</a>
</div>
The quick way;
#Links {
width:650px;
background-color: #dcdcdc;
border: #00008b 2px dashed;
}
#Links > a {
display: block;
}
<div id="Links">
Index Page
Schedule Page
To Top
</div>
The semantically correct way;
#Links {
list-style-type: none;
width:650px;
background-color: #dcdcdc;
border: #00008b 2px dashed;
}
#Links > a {
display: list-item;
}
<nav id="Links">
Index Page
Schedule Page
To Top
</nav>
Cheers!
The a tag belongs to the inline elements. With the css rule display:block you can let them behave like block elements.
#Links a {
display: block;
}
<div id="Links" style="width:650px; background-color: #dcdcdc; border: #00008b 2px dashed;">
Index Page
Schedule Page
To Top
</div>
I am trying to add social media buttons to my WordPress page via HTML code:
However, they styling does not work, they take up the entire page and are much too big. Why does this happen, and can I fix it?
Here is the code:
<style type="text/css">
#share-buttons img {
width: 35px;
padding: 5px;
border: 0;
box-shadow: 0;
display: inline;
}
</style>
<div id="share-buttons">
<!-- Facebook -->
<a href="http://www.facebook.com/sharer.php?u=http://www.jusskaur.com/blog/workshop-with-senior-ladies/" target="_blank">
<img src="http://www.jusskaur.com/wp-content/uploads/2016/06/facebook.png" width="35" height="35" alt="Facebook" />
</a>
<!-- Twitter -->
<a href="https://twitter.com/share?url=http://www.jusskaur.com/blog/workshop-with-senior-ladies/&text=Simple%20Share%20Buttons&hashtags=simplesharebuttons" target="_blank">
<img src="http://www.jusskaur.com/wp-content/uploads/2016/06/twitter.png" alt="Twitter" />
</a>
<!-- Google+ -->
<a href="https://plus.google.com/share?url=http://www.jusskaur.com/blog/workshop-with-senior-ladies/" target="_blank">
<img src="http://www.jusskaur.com/wp-content/uploads/2016/06/google.png" alt="Google" />
</a>
<!-- LinkedIn -->
<a href="http://www.linkedin.com/shareArticle?mini=true&url=http://www.jusskaur.com/blog/workshop-with-senior-ladies/" target="_blank">
<img src="http://www.jusskaur.com/wp-content/uploads/2016/06/linkedin.png" alt="LinkedIn" />
</a>
<!-- Pinterest -->
<a>
<img src="http://www.jusskaur.com/wp-content/uploads/2016/06/pinterest.png" alt="Pinterest" />
</a>
<!-- Email -->
<a href="mailto:?Subject=Simple Share Buttons&Body=I%20saw%20this%20and%20thought%20of%20you!%20 https://simplesharebuttons.com">
<img src="http://www.jusskaur.com/wp-content/uploads/2016/06/email.png" alt="Email" />
</a>
</div>
When a style is being overwritten by another style, the best fix is to use a stronger selector:
#share-buttons a img { /* added 'a' */
width: 35px;
padding: 5px;
border: 0;
box-shadow: 0;
display: inline;
}
For a more in-depth explanation of CSS specificity, read this CSS Tricks article.
instead, define a specific size for the 'a' tags and set the images to be 100% width.
#share-buttons a { width:35px, display:inline-block}
#share-buttons a img {width: 100%}
also, remove the width parameter in the 'a' tags
Add this,
#share-buttons {
width: 100%;
height:auto;
padding: 5px;
border: 0;
box-shadow: 0;
display: inline;
}
#share-buttons > a{
text-decoration:none;
}
#share-buttons > a > img{
width:35px;
height:35px;
}
#share-buttons img {
max-width: 100%;
height: auto;
}
#share-buttons a {
width: 35px !important;
padding: 5px;
border: 0;
box-shadow: 0;
display: inline-block;
}
I do not want the picture to be underlined, but I need the hyperlink in the text to be underlined. How can I do that? It is a wordpress theme so I can't change the html I have to stay with css
.post-desc a{
border-bottom: 1px solid #FBCF00;
}
.post-desc a img{
border-bottom: none;
}
<div class="post-desc">
<img class="alignnone wp-image-2763 size-full" src="http://www.montrealguidecondo.ca/news/wp-content/uploads/2016/01/exterieur-1.jpg" alt="extérieur de Tod condo" width="639" height="438">
</div>
You can remove it under the image using display:table; on image, like this:
.post-desc a img{
border-bottom: none;
display:table;
}
Snippet:
.post-desc a {
border-bottom: 1px solid #FBCF00;
}
.post-desc a img {
border-bottom: none;
display: table;
}
<div class="post-desc">
<a href="http://www.montrealguidecondo.ca/news/wp-content/uploads/2016/01/exterieur-1.jpg" target="_blank" rel="attachment wp-att-2763">
<img class="alignnone wp-image-2763 size-full" src="http://www.montrealguidecondo.ca/news/wp-content/uploads/2016/01/exterieur-1.jpg" alt="extérieur de Tod condo" width="639" height="438">
</a>
</div>
to make it simple you may use vertical-align with a negative value to drop img as much as needed under the base line:
a {
border-bottom: solid;
}
a img {
vertical-align: -0.5em;/* average -0.25em equals vertical-align:bottom */
/* demo purpose: see border under img */
opacity:0.75;
}
text
<a href="#">
<img src="http://dummyimage.com/60" />
</a>
within the last stylesheet of your website , test this
a img {
margin-top:0.5em;
vertical-align: -0.5em;
}
or if you like better:
a img {
position:relative;
top: 0.5em;
}
The idea is to hide the border with the image itself
Text decoration underline
<div><a style="text-decoration:underline" href="http://www.montrealguidecondo.ca/news/wp-content/uploads/2016/01/exterieur-1.jpg" target="_blank" rel="attachment wp-att-2763"><img class="alignnone wp-image-2763 size-full" src="http://www.montrealguidecondo.ca/news/wp-content/uploads/2016/01/exterieur-1.jpg" alt="extérieur de Tod condo" width="639" height="438"></a>
You have set the border attributes on the <a> tags, so you can't just remove them on the containing <img> elements. Unfortunately, there is no "conatining" selector in css (yet) and apparently you can't edit the html, so we have to stick with the informations we've got.
The links with the containing images have the word attachment in the attribute rel. This is how to select them and disable their border:
a[rel~="attachment"] {
border-bottom: none !important;
}
I'm trying to build an image gallery with thumbnails and a display for a larger image. At present, its working when the the mouse hovers over the thumbnail which displays the larger image. However I wish to replace the hover feature with an on click so that the larger image does not disappear when the mouse leaves the thumbnail. From a bit of research I'm lead to believe that this can not be done with css as with the hover feature and that I would need to include some script. As I'm new to web development after this I'm a bit lost and would appreciate some help. Below is the html code for the gallery container and the corresponding css code......where do I start from here?
Thanks
A
html code
<div class="gallerycontainer">
<a class="thumbnail" href="#thumb"><img src="images/gallery/1one/101.jpg" width="56px" height="80px" border="0" /><span><img src="images/gallery/1one/101.jpg" width="405px" height="585px"/></span></a>
<a class="thumbnail" href="#thumb"><img src="images/gallery/1one/102.jpg" width="56px" height="80px" border="0" /><span><img src="images/gallery/1one/102.jpg" width="405px" height="585px"/></span></a>
<a class="thumbnail" href="#thumb"><img src="images/gallery/1one/103.jpg" width="56px" height="80px" border="0" /><span><img src="images/gallery/1one/103.jpg" width="405px" height="585px"/></span></a>
<a class="thumbnail" href="#thumb"><img src="images/gallery/1one/104.jpg" width="56px" height="80px"border="0" /><span><img src="images/gallery/1one/104.jpg" width="405px" height="585px"/></span></a>
<br />
</div>
css code
.gallerycontainer{
position: absolute;
/*Add a height attribute and set to largest image's height to prevent overlaying*/
}
.thumbnail img{
border: 1px solid white;
margin: 0 5px 5px 0;
}
.thumbnail:hover{
background-color: transparent;
}
.thumbnail:hover img{
border: 1px solid grey;
}
.thumbnail span{ /*CSS for enlarged image*/
position: absolute;
background-color: #000000;
padding: 5px;
left: -1000px;
border: none;
visibility: hidden;
color: black;
text-decoration: none;
}
.thumbnail span img{ /*CSS for enlarged image*/
border-width: 0;
padding: 2px;
}
.thumbnail:hover span{ /*CSS for enlarged image*/
visibility: visible;
top: 0;
left: 300px; /*position where enlarged image should offset horizontally */
z-index: 50;
}
Heres a simple start with jquery.
http://jsfiddle.net/8GKXM/
$('.thumbnail').each(function(){
$(this).click(function() {
$('.thumbnail span').hide();
$(this).find('span').show('slow');
});
});
This is what the jquery says basically:
On every individual .thumbnail click:
hide .thumbnail span ( as in every span it finds )
then
find clicked .thumbnail's span and show that
I would probably move the bigger images into their own container though...
You can use jQuery along with blockUI plugin:
<div class="gallerycontainer">
<a class="thumbnail" href="#thumb" class="imgthumb"><img src="images/gallery
/1one/101.jpg" width="56px" height="80px" border="0" /></a>
<a class="thumbnail" href="#thumb" class="imgthumb"><img src="images/gallery
/1one/102.jpg" width="56px" height="80px" border="0" /></a>
</div>
And then you can use the window onload event to attach the onclick event to fire the large image with blockUI:
$(function(){
$(".imgthumb").onclick(function() {
$.blockUI({
message: "<div><img src=" + $(this + " > img").attr("src") + " width='405' height='585' /></div>";
css: { border: '1px solid grey'}
});
});
});
Hello I have 3 flags (Italian, german, english) with the purpose to change language for the whole site in future. How can I make a border on a hover effect that could alxo work with IE ?
this is the CCS
.miniflags {
float:right
margin : 5px 20px;
padding-right:10px;
}
and here the HTML
<div id="bandiere">
<a><img src="ita.png" class="miniflags" /></a>
<a><img src="ger.png" class="miniflags" /></a>
<a><img src="eng.png" class="miniflags" /></a>
</div>
Thanx for help
Alex
add
.miniflags img:hover {
border: 1px solid #000;
}
or
.miniflags a:hover {
border: 1px solid #000;
}
to your css
i believe the 2nd will work better (a:hover)
If you apply the miniflags class to the <a> instead, the :hover pseudoselector will work.
The miniflags class hardly seems necessary. Just remember that :hover works only for links in older versions of IE, so you will need to apply it to the <a> tags instead of the <img>.
<div id="bandiere">
<a><img src="ita.png" /></a>
<a><img src="ger.png" /></a>
<a><img src="eng.png" /></a>
</div>
<style type="text/css">
#bandiere img {
float:right
margin : 5px 20px;
padding-right:10px;
}
#bandiere a:hover, #bandiere a:focus {
border: 1px solid red;
}
</style>
IE (until 6 IIRC) only allows hover for links. So you'd have to add the :hover to the a not to the image. The <a> must have a href attribute for this to work of course.