Replicate a table with div-css - html

I have a website wallz.moon.pk, it's a wallpaper collection, on the gallery where I show thumbnails I have created a mouse over effect that for mouse a semi transparent strip is shown over the thumbnail so that user can select an appropriate answer..
I am not very good with DIVs so I put in a table to create the effect I wanted, check it out here, I have used the following code:
<div id="i551" class="actions">
<table width="100%" cellpadding="0" cellspacing="0">
<tr>
<td align="center" colspan="2"><h2>Water Bubbles</h2></td>
</tr>
<tr>
<td width="50%">
Open Here
</td>
<td width="50%">
<a href="Water+Bubbles.html" class="acthuns" target="_blank">
+ New Tab </a>
</td>
</tr>
</table>
</div>
My question is how to convert the above Table and used DIVs & CSS styling to get the same effect....

Here is a simple approach:
http://jsfiddle.net/tNms9/3/
HTML
<div id="i551" class="actions">
<div class="row">
<h2>Water Bubbles</h2>
</div>
<div class="row">
<div class="cell">
Open Here
</div>
<div class="cell">
<a href="Water+Bubbles.html" class="acthuns" target="_blank">
+ New Tab </a>
</div>
</div>
</div>​
CSS
.actions{ width:400px; }
.row { width:100%; overflow:hidden; background:lime; }
.cell {width:45%; padding:10px; float:left; background:orange; }​

In CSS 2.1, the display property have Table model values which allows you to set the display of a element to each <table> known element : https://developer.mozilla.org/en-US/docs/CSS/display#Values
PS : It doesn't work on IE7-.

The provided code will produces the first row of images. You can mess with the percentages to get the white space you want, but here is the basic idea:
CSS:
.tile-container {
width:100%;
margin-left:-2%; /* offsets the first column of tiles */
}
.tile {
float:left;
width:23%;
margin-left:2%;
margin-bottom:2%;
}
HTML:
<div class="tile-container">
<div class="tile>
<!-- Image + other markup goes here -->
<div>
<div class="tile>
<!-- Image + other markup goes here -->
<div>
<div class="tile>
<!-- Image + other markup goes here -->
<div>
<div class="tile>
<!-- Image + other markup goes here -->
<div>
</div>

Related

Image alignment issue in html

I am creating a small page using html which has a header and a body. The header is within a tag with blue background.
The problem I am facing is an image(android.png) which I want to be displayed in right end of the header seems getting placed below the header. How can I place the image in the right of the header.
I don't want to use CSS to align the image.
Click Run Code Snippet to view the current page layout
<html>
<body>
<div style="width:400px;height:60px;border:1px solid blue;background-color:#2196F3"">
<img align="left" width="80px" height="50px" src="http://icons.iconarchive.com/icons/igh0zt/ios7-style-metro-ui/512/MetroUI-Google-Gmail-icon.png">
<div text-align="left" style="font-size:20px;color:white"><h3>Something</h3></div>
<img align="right" width=150px height=50px src="http://www.sona-systems.com/img/android.png">
</div>
<div style="width:400px;height:400px;border:1px solid blue">
<p>
Hey,<br>
I am on vacation. I will respond after i come back</p>
<i><p>Sent from gmail</p></i>
</div>
</body>
</html>
I think this does what you're after. Your text div inside the header was filling out the rest of the width, pushing the second image to the next row:
<html>
<body>
<div style="width:400px;height:60px;border:1px solid blue;background-color:#2196F3">
<img style="float:left; width:80px;height:50px" src="http://icons.iconarchive.com/icons/igh0zt/ios7-style-metro-ui/512/MetroUI-Google-Gmail-icon.png">
<div style="font-size:20px;color:white; text-align:left; float:left">
<h3>Something</h3>
</div>
<img style="float:right; width:150px; heigh:50px; margin-top:5px; margin-right:5px" src="http://www.sona-systems.com/img/android.png">
</div>
<div style="width:400px;height:400px;border:1px solid blue">
<p>
Hey,
<br>I am on vacation. I will respond after i come back</p>
<i><p>Sent from gmail</p></i>
</div>
</body>
</html>
jsBin demo
Learn to use <style>. Makes life easier and more time to drink coffee with friends.
Float your image to the right
But also since H3 is a block element by default float it left (to remove the width)
<p> should not be enclosed in <i> since Paragraphs are block level elements and i are inline
<style>
.float-left{ float:left;}
.float-right{float:right;}
#header{
width:400px;
height:60px;
border:1px solid blue;
background-color:#2196F3;
}
#header img{
height:50px;
}
#header h3{
font-size:20px;
color:white;
}
#content{
width:400px;
height:400px;
border:1px solid blue;
}
</style>
HTML
<div id="header">
<img class="float-left" src="http://icons.iconarchive.com/icons/igh0zt/ios7-style-metro-ui/512/MetroUI-Google-Gmail-icon.png">
<h3 class="float-left">Something</h3>
<img class="float-right" src="http://www.sona-systems.com/img/android.png">
</div>
<div id="content">
<p>
Hey,<br>
I am on vacation. I will respond after i come back
</p>
<p><i>Sent from gmail</i></p>
</div>
Another solution would be to place your images right inside the H3 element
<h3><img> Some Text <img></h3>
but than you need to play with the H3's line-height and the image's vertical-align etc.
Since you want to avoid CSS, I'll assume this is for output to an HTML-handicapped email client such as Outlook.
You can do this without using CSS on your images by simply moving the second image before the first one within the HTML.
<html>
<body>
<div style="width:400px;height:60px;border:1px solid blue;background-color:#2196F3"">
<img align="right" width=150px height=50px src="http://www.sona-systems.com/img/android.png">
<img align="left" width="80px" height="50px" src="http://icons.iconarchive.com/icons/igh0zt/ios7-style-metro-ui/512/MetroUI-Google-Gmail-icon.png">
<div text-align="left" style="font-size:20px;color:white"><h3>Something</h3></div>
</div>
<div style="width:400px;height:400px;border:1px solid blue">
<p>
Hey,<br>
I am on vacation. I will respond after i come back</p>
<i><p>Sent from gmail</p></i>
</div>
</body>
</html>
I fixed this (it will still need some brushing up, but it works) by switching the position in the code where the <div> with "Something" in it and the messed up image are.
Instead of
<div text-align="left" style="font-size:20px;color:white;"<h3>Something</h3></div>
<img align="right" width=150px height=50px src="http://www.sona-systems.com/img/android.png">
Do
<img align="right" width="150px" height="50px" src="http://www.sona-systems.com/img/android.png"> <!--added in quotes for the width and height-->
<div text-align="left" style="font-size:20px;color:white;"<h3>Something</h3></div>
You also have some a wrong double quote in this line

Table not getting resized inside a div on resizing the div

I have a table in my jsp inside a div which is resizeable.
When I'm resizing the div, I'm not able to resize the height of table inside where as width of table is getting resized. Following is my snippet. Please check once.
<div id="id" style="height:350px; width250px;" class="control">
<div id="fifth_heading" class="heading_control">
<i class="fa2 fa-fifth"></i>
<p><%=entry1.getDivdescription() %></p>
<div class="button_right_second">
<i class="fa3 fa-second3" id="<%=entry1.getDivid() %>"></i>
</div>
</div>
<div class="fifth_dropdown">
<div class="table_data" id="table_second">
<table id="example3" style="height:auto;"class="display" border="0" cellspacing="0" cellpadding="0">
<!-- the below tr prints the dates -->
<tbody>
<tr id="line1">
<td>
<span id="header_title">Your Current Lead Time</span>
</td>
</tr>
<tr id="line2">
<td>
<span id="value">alignvalue</span>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
div.table_data{margin-left:2px;margin-right:10px;margin-top:5px;overflow:auto;}
#table_second::-webkit-scrollbar{
width:10px;
background-color:#cccccc;
}
#table_second::-webkit-scrollbar-thumb{
background-color:rgb(78, 82, 93);
border-radius:10px;
}
#table_second::-webkit-scrollbar-thumb:hover{
background-color:rgb(78, 82, 93);
border:1px solid #333333;
}
#table_second::-webkit-scrollbar-thumb:active{
background-color:rgb(78, 82, 93);
border:1px solid #333333;
}
Try setting the height of your table to 100% and explicitly setting the div's height.
Answer as per this post: link
Not sure which <div> you want to resize but you can try one of these...
If you want to resize the <div id="id" ... class="control"> to make your <table> resized, try to add the height property in your div.table_data with % percent unit.
If you like to resize your <div> and <table>, you must set the height your <div> with class control, div.table_data and your <table> to 100% or any value (from 0-100) with % percent unit.
My code snippet after doing that...
CSS
div.table_data
{
margin-left:2px;
margin-right:10px;
margin-top:5px;
overflow:auto;
height:70%;
background-color:#ccffcc;
}
(Excluded the -webkit-scrollbar)
HTML
<div id="id" style="height:100%; width250px;background-color:#ff9999;" class="control">
<div id="fifth_heading" class="heading_control">
<i class="fa2 fa-fifth"></i>
<p>dddddddd</p>
<div class="button_right_second">
<i class="fa3 fa-second3" id="ddd"></i>
</div>
</div>
<div class="fifth_dropdown">
<div class="table_data" id="table_second">
<table id="example3" style="height:100%;" class="display" border="1" cellspacing="0" cellpadding="0">
<!-- the below tr prints the dates -->
<tbody>
<tr id="line1">
<td>
<span id="header_title">Your Current Lead Time</span>
</td>
</tr>
<tr id="line2">
<td>
<span id="value">alignvalue</span>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
This snippet can make the two <div> and your <table> will be re-sized when the window is re-sized.
If you don't like that your <table> will be too small if the size of your window is too small, you can use the min-height CSS property. For bigger sizes, use max-height.

How to add cols on top of image in bootstrap

Please i am new to bootstrap. Recently lean the grids etc. I am trying to add controls like a table or on top of an image exactly like the search and the testimonial one here . Just from the example, i dont want by whole site on top the image. Just one row.
<div class='container-fluid'>
<div class='row' style='position:absolute; z-index=-1'>
<img src='images/banner.jpg' alt='Blast off with Bootstrap' />
</div>
<!-- My other controls goes here, example my table etc. -->
</div>
<div class='container'>
<!-- I dont like what ever is in this container to display on top the image above.-->
</div>
When i run my code , everything displays on the image including the second container. Please how do i archive that? Any help is highly appreciated.
check out this code i had provided the working example
<div class='container-fluid'>
<div class='row banner'>
<img src='http://images.visitcanberra.com.au/images/canberra_hero_image.jpg' alt='Blast off with Bootstrap' />
<div class="table-block">
<table>
<tr>
<th>Firstname</th>
<th>Lastname</th>
<th>Savings</th>
</tr>
<tr>
<td>Peter</td>
<td>Griffin</td>
<td>$100</td>
</tr>
<tr>
<td>Lois</td>
<td>Griffin</td>
<td>$150</td>
</tr>
</table>
</div>
</div>
<!-- My other controls goes here, example my table etc. -->
</div>
<div class='container'>
<!-- I dont like what ever is in this container to display on top the image above.-->
</div>
CSS code :
img{
width:100%;
height:200px;
}
table, td, th {
border: 1px solid #111;
}
table {
width: 400px;
}
.table-block{
position:absolute;
top:25px;
left:25px;
}
.banner{position:relative;}
working example

How to center container with unknown width and floated elements inside on fluid page

I know there are lots of ways to center content with an unknown width on a fluid width page in HTML/CSS but I can't get them to work in this case for some reason and need help.
Firstly, let me state that I need a solution that works in common browsers and in IE6 (don't ask why).
Here's an example of markup and the problem. In this example I want the yellow boxes centered inside the blue box.
example on jsfiddle.net
<div style="background:blue;margin:0 auto;width:100%;">
<table style="margin:0 auto;">
<tr>
<td>
<div style="background:yellow;float:left;padding:50px;">Test</div>
<div style="background:yellow;float:left;padding:50px;">Test</div>
<div style="background:yellow;float:left;padding:50px;">Test</div>
<div style="background:yellow;float:left;padding:50px;">Test</div>
<div style="background:yellow;float:left;padding:50px;">Test</div>
<div style="background:yellow;float:left;padding:50px;">Test</div>
<td>
</tr>
</table>
</div>
I tried this method using a table but I also tried the -50% +50% method. I am happy to use any method that works on all common browsers and IE6.
Can someone help me fix it.
Please do not lecture me on IE6 or incorrect use of the TABLE tag.
Try this,
<tr>
<td>
<div style="width: 379px;">
<div style="background:yellow;float:left;padding:50px;">Test</div>
<div style="background:yellow;float:left;padding:50px;">Test</div>
<div style="background:yellow;float:left;padding:50px;">Test</div>
<div style="background:yellow;float:left;padding:50px;">Test</div>
<div style="background:yellow;float:left;padding:50px;">Test</div>
<div style="background:yellow;float:left;padding:50px;">Test</div>
</div>
</td>
</tr>
what I understood from your requirement that you want to make your div to center ? then please have a look on the below code
<style type="text/css">
.yourclass
{
background:yellow;
float:left;
padding:50px;
}
.blueback
{
background:blue;
}
.mytable
{
width: auto;
margin-left: auto;
margin-right: auto;
}
div.clear
{
clear:both;
}
</style>
<div class="blueback">
<table class="mytable">
<tr>
<td>
<div class="yourclass">Test</div>
<div class="yourclass">Test</div>
<div class="yourclass">Test</div>
<div class="clear"></div>
<div class="yourclass">Test</div>
<div class="yourclass">Test</div>
<div class="yourclass">Test</div>
</td>
</tr>
</table>
Hope it helps...
After lots of research I can find no solution to this that works in all browsers and doesn't require IE6 hacks.
The best solution is display:inline-block and IE6/7 and various other hacks (eg. FF2).
The final solution taken from here is as follows:
<style>
li {
width: 200px;
min-height: 250px;
border: 1px solid #000;
display: -moz-inline-stack;
display: inline-block;
vertical-align: top;
margin: 5px;
zoom: 1;
*display: inline;
_height: 250px;
}
</style>
<li>
<div>
<h4>This is awesome</h4>
<img src="http://farm4.static.flickr.com/3623/3279671785_d1f2e665b6_s.jpg"
alt="lobster" width="75" height="75"/>
</div>
</li>

CSS table styles

CSS is my weak side and now I'm trying to improve it, can you please help me to spot what's the problem is, moreover which css style I'm missing.
<table>
<tr>
<td style=width:"177px; height:92px"><img src="logo.png"></td>
<td rowspan="2"><img src="img2.png"></td>
</tr>
<tr>
<td style=width:"177px; height:100px"><img src="img1.png"></td>
</tr>
</tr>
</table>
UPDATE:
I forgot to mention that I was doing HTML email so solved my issue. Thanks for your help
I think you just need to make the table default CellSpacing and CellPadding 0 (assuming the top picture in your post is the desired result)
<table cellpadding=0 cellspacing=0 >
Although DIV's may be easier
<div>
<div style = width:"177px; height:92px; float:left;">
<img src="logo.png"><br />
<img src="img2.png">
</div>
<div style=width:"177px; height:100px; float:left;">
<img src="img1.png">
</div>
</div>
Then, let's take it 1 step further
<style>
.wrapper
{
background-color:#ccc;
padding:5px;
}
.content
{
width:177px;
height:100px; /*Made them both 100px although one was 92px, this may not be correct*/
float:left;
}
</style>
<div class="wrapper">
<div class="content">
<img src="logo.png"><br />
<img src="img2.png">
</div><!--/content-->
<div class="content">
<img src="img1.png">
</div><!--/content-->
</div><!--/wrapper-->
The property you are looking for may be border-spacing, E.G. border-spacing: 0; (other table specific CSS properties) however you may wish to consult this topic first: Why not use tables for layout in HTML?
Try This one:
css
table {border:1px solid #ccc;
.logo{ width:100px; }.img2{ width:300px }
HTML
<table cellpadding="0" cellspacing="0">
<tr>
<td class="logo">
<img src="logo.png" /><br />
<img src="img1.png">
</td>
<td class="img2"><img src="img2.png"></td>
</tr>
</table>
height is the problem. Decrease the height of logo.png image.