Stretch div as much as possible within a table cell - html

I am currently working on a personal website which will contain pictures. I wanted to create a frame for those pictrues, so I sliced a photo of the frame into pieces and made each piece a div, since I want a certain part of the frame pic to stretch but not the edges, e.g. Here's my table:
<table>
<tr>
<td height="93px" width="93px"><div id="photo_corner_topleft"></div></td>
<td height="93px"><div id="photo_beggining_top"></div><div id="photo_side_top"></div><div id="photo_ending_top"></div></td>
<td height="93px" width="93px"><div id="photo_corner_topright"></div></td>
</tr>
<tr>
<td width="93px"><div id="photo_beggining_left"></div><div id="photo_side_left"></div><div id="photo_ending_left"></div></td>
<td>
<div id="photo_content" align="center">
<!-- HERE goes the photo. -->
</div>
</td>
<td width="93px"><div id="photo_beggining_right"></div><div id="photo_side_right"></div> <div id="photo_ending_right"></div></td>
</tr>
<tr>
<td height="93px" width="93px"><div id="photo_corner_bottomleft"></div></td>
<td><div id="photo_beggining_bottom"></div><div id="photo_side_bottom"></div><div id="photo_ending_bottom"></div></td>
<td height="93px" width="93px"><div id="photo_corner_bottomright"></div></td>
</tr>
</table>
So, I want the divs "photo_side_whatever" to be as long as possible without pushing the "ending" and "beggining" divs out. I have checked other questions but I still haven't managed to make it. Here is my div:
#photo_side_left {
min-height: 224px;
width: 93px;
height: auto;
background-image: url(img/dynamic_frame/frame_09.png);
background-position: center;
background-repeat: no-repeat;
background-size: contain;
}

Insert this at the beginning of your div. Is this live anywhere so I can better understand your question?
position:absolute;

There's no way to do it that will work in all browsers (the CSS3 background-size property should be able to do it, but AFAIK it's not fully supported yet). The easiest thing to do, I'd have thought, would be to set the background image within the <td>s to be a small slice (by which I mean about 1-2px on its shortest side) of the frame, set to repeat.
Something like:
#photo_side_left {
background-image: url('img/dynamic_frame/frameslice.png');
background-repeat:repeat-y;
min-height: 224px;
width: 93px;
height: auto;
background-position: center;
background-repeat: no-repeat;
}
EDIT: Apply that to the <td>, rather than bothering with <div>s. The td will always be the right size ^^

Related

HTML newsletter - Overlay text on various parts of an image, possibly using tables

We're trying to make an HTML newsletter with an image background of a scroll (something like http://images.clipartpanda.com/blank-scroll-clip-art-ancient-parchment-scroll-Download-Royalty-free-Vector-File-EPS-2942.jpg), and would like to have the ability to place text in specific areas of it. Ideally, we'd like to be able to easily place text in the top area (the rolled up section), in the middle, or at the bottom (again, in the rolled up section).
What's the best way to do this? We were experimenting with using the image as a background to a table, and using table cells to try to line up with the image areas, but struggled to get this to work.
Should we be trying to split the image into three separate images (top, middle, bottom) and using these as backgrounds for a table with three rows, or is that likely to not work well?
Apologies for our ignorance. Our HTML skills aren't really there; we just want a simple layout that we can use for newsletters.
EDIT: Here's what we're currently trying:
<html>
<head>
</head>
<body>
<table style="height: 600px; width: 600px; background-image: url(http://cliparts.co/cliparts/qiB/orL/qiBorL8gT.jpg); background-repeat: no-repeat; background-size: 100% 100%; background-origin: content-box">
<tbody>
<tr>
<td class="">
<table style="height: 500px; width: 400px; margin: auto;">
<tbody>
<tr style="height: 100px;">
<td>This is some text in the top area</td>
</tr>
<tr style="height: 400px;">
<td>This is the main text</td>
</tr>
<tr style="height: 100px;">
<td>This is some text in the bottom area</td>
</tr>
</tbody>
</table>
<br>
</td>
</tr>
</tbody>
</table>
<br>
</body>
</html>
I appreciate that this might be the wrong approach these days, though; what would be a better approach? Is this really outdated now?

Can't size <DIV> height correctly on mobile

First, I'm new to mobile development, so apologies in advance for what might be a simple question. But I've researched this for a couple of days and just can't seem to get it to work.
I can't get a particular DIV to render at the appropriate height when I switch to a mobile view. All the other divs work fine in both desktop and mobile. The div in question looks fine in the desktop view but not in mobile.
Here's a link to the page: http://echoflyfishing.com/2016
The div in question is the "DOUBLE HAND". I want it the same height as the "SINGLE HAND" above it. No matter what I do, I can't get it to size correctly. I know there's a simple solution but I've tried everything I can think of in terms of height and am stumped.
Here's the relevant HTML:
<div class="sh_container_m">
<table cellpadding="0" cellspacing="0" class="sh_container_table_m">
<tr>
<td style="font-size: 3.5vw;padding-top: 2vw; padding-bottom: 2vw;"><p>Single Hand</p></td>
</tr>
</table>
<div class="sh_images_container_m">
<table cellpadding="0" cellspacing="0">
<tr>
<td>This is where the single hand image carousel will be</td>
</tr>
</table>
<div class="dh_container_m">
<table cellpadding="0" cellspacing="0" class="dh_container_table_m">
<tr>
<td style="font-size: 3.5vw;"><p>Double Hand</p></td>
</tr>
</table>
<div class="dh_images_container_m">
<table cellpadding="0" cellspacing="0">
<tr>
<td>This is where the double hand image carousel will be</td>
</tr>
</table>
</div>
</div>
</div>
</div>
And the CSS:
.dh_container_m
{
display: block;
visibility: hidden;
margin: 0 auto;
width: 100vw;
text-align: center;
}
.dh_container_table_m
{
margin: 0 auto;
width: 100vw;
border: none;
background-color: #fbaa27 !important;
}
Did you mean for your dh_images_container_m div to be nested inside the sh_images_container_m div? It is going to take on it's "parents" properties which may also be contributing to some of your sizing issues.
On a side note, you have your links to the css files in the header as type="text". They should be type="css/text".
use px not vw because it's percentage and define the width of both divs as you want simple one more suggestion is use bootstrap css framework it's better for you you can make responsive site easily with the help of it.

3 column table, widths: auto, 50%, 50%, overflow hidden

I'm trying to recreate a daily schedule view in a mobile website design. The PC version looks like this:
It will have several rows, and up to 5 or 6 columns. I think a table will be best, but can't find the right CSS/HTML to get this to work how I want.
I want the first column to have an auto width, to fit the content, and the rest to be equal (evenly distributed). The entire table will be 100% width.
I can get this by setting the column widths as follows: 0; 50%; 50%; -- and not using table-layout: fixed; The problem is, I can't have the width of any cells getting wider just because the content is too large. If I use table-layout: fixed, it keeps the cells the correct size, but the first column is 0 width, instead of auto/fit. I tried placing the content inside each cell in a span or div and setting those to: width: 100%; overflow: hidden;, but I don't think the width: 100% really works inside a table that isn't fixed.
If I really have to, I'll set a fixed width for the first column, but I'd like to avoid this because I don't want to use fixed font sizes -- especially because this will be a mobile website, for smart-phones and tablets.
I might be able to do something by using nested tables or floats... the first column not being part of the same table, but I'm hoping there is a super clean solution I'm missing, and I can keep all of this in a single table.
EDIT: As requested, here is one version of my code that I have tried. The styles with x in front of the names are just different things I have tried (I add the x to quickly remove, and easily put back):
<table cellpadding="0" cellspacing="0" style="width: 100%; xwhite-space: nowrap; xtable-layout: fixed;">
<tr>
<td style="width: 0; background-color: Lime;">
Time
</td>
<td style="width: 50%; background-color: Silver;">
ERIC
</td>
<td style="width: 50%; background-color: Gray;">
DONNA
</td>
</tr>
<tr>
<td>8:00am</td><td> </td><td>Do Something</td>
</tr>
<tr>
<td>9:00am</td><td style="width: 50%; overflow: hidden;"><div style="width: 100%; height: 100%; overflow: hidden;">Do Something else with more text so we can see how this works when too long and really longer than it ever should be</div></td><td style="width: 50%;"> </td>
</tr>
</table>
The above version is as close as I've got, but the long text for "ERIC" at 9am wraps to multiple lines. If I change it to not wrap, then the cell gets too wide (even with overflow: hidden).
Your table width is 100% and the second and third columns are width 50% each and your first column is 0%. Definitely, it doesn't work because it has already used up the 100% width for the second and third columns.
In case it isn't possible to do what I want with one table, here is a nested table solution that doesn't seem as bad as I thought:
<table cellpadding="0" cellspacing="0" style="width: 100%;">
<tr>
<td style="width: 0;">
<table cellpadding="0" cellspacing="0">
<tr><td>Time</td></tr>
<tr><td>8:00am</td></tr>
<tr><td>9:00am</td></tr>
</table>
</td>
<td>
<table cellpadding="0" cellspacing="0" style="width: 100%; table-layout: fixed; white-space: nowrap;">
<tr><td>ERIC</td><td>DONNA</td></tr>
<tr><td style="overflow: hidden;">This cell has a lot of text so that I can test for overflow issues even if I make my browser window very wide</td><td> </td></tr>
<tr><td> </td><td>Whatever</td></tr>
</table>
</td>
</tr>
</table>
Fiddle: http://jsfiddle.net/fWFPm/4/

CSS hover creating hotspot in entire table row

I recently applied a hover feature to a set of buttons. When applied to a different website the coding was fine. When applied to this site the link/hotspot goes to the next button. For example: I have buttons home/about/gallery/blog/prints/contact and you would think with the dimensions set in CSS style sheet that the link would only apply to those dimensions. Not with this one. The link/hotspot shows linked to index.shtml from the edge of the table to the other side of the home button. There are spaces between buttons but the link/hotspot goes 50%across the space until it hits the next buttons link/hotspot. And the final button "contact" spans across to the opposite edge of the table. Any clues as to what I am doing wrong?
CSS:
div.nav-home {
margin-top: 10px;
margin-bottom: 0px;
margin-left: 130px;
Margin-right: -60px;
background-position: right top;
background-repeat: no-repeat;
width: 75px;
height: 64px;
}
#home {
background-image: url('img/home.png');
}
#home:hover {
background-image: url('img/home_hover.png');
}
Index.shtml:
<table width="1213" height="64" align="center" background="img/tablebg2.png">
<!--#include file="menubuttons.html" -->
menubuttons.html:
<tr>
<td align="center" width="75">
</div>
</td>
<td align="center" width="86">
</div>
</td>
<td align="center" width="94">
<a href="/gallery.shtml" title="GALLERY" ><div id="gallery" class="nav-gallery">
</div></a>
</td>
<td align="center" width="63">
</div>
</td>
<td align="center" width="85">
<a href="/prints.shtml" title="PRINTS" ><div id="prints" class="nav-prints">
</div></a>
</td>
<td align="center" width="103">
<a href="/contact.shtml" title="CONTACT" ><div id="contact" class="nav-contact">
</div></a>
</td>
</tr>
FIXED: (maybe not properly?)
I have only been coding for 2 months and have a pretty good idea on how to write it out, but I don't know what everything means such as the DIV tag. I know I was searching on here last night and I assumed I was to put the div inside a TD.
I was able to fix everything by simply adding a few spacer.png's before the first button in between each set of buttons and after the last button. This also fixed my spacing issues on the sides.
Thanks for the help. I simply am trying to find an easy way to make my buttons change on hover. This method was the first I found last night on here and am now trying to perfect it.. well in my head at least. I need to research on the unordered list a little because I have heard that that makes things more simple...
Here is the link(based off the back end of a site I recently finished) www.blackmarkettattoos.com/amysesco/index.shtml
I think the problem is the fact that you are using DIV, which is a container tag inside table's cell, and for both you apply style (to the DIV as class and to the TD as inline).
Generally, it is better to create menus with lists, but if you must use the code you provided, then try to remove width: 75px; from the div.nav-home.
Check these two links for how to create CSS menus with lists:
css.maxdesign.com.au
Dynamic Drive CSS Library

border on side to continue all the way down dynamic page?

Have a border, bgr_left.jpg, that I want to continue down the y-axel on my page...
the bgr_left.jpg is 30px by 30px and I have placed it in a div tag... Also I want the same border on the right side, and on the top all the way across...
I cant get this done, heres my css for the left border:
.bgr_left {
background-image: url(../Graphics/bgr_left.jpg);
background-repeat: repeat-y;
background-position: left;
position: absolute;
left: 0px;
top: 0px;
height: 100%;
width: 30px;
background-color: #E7F5F0;
}
Thanks for all help
You can do this using a table or by dynamically sizing a div.
Table method
Although something like this should fine in a web browser, search engines and other computer consumers might misinterpret it because you using the table tag to markup non-tabular content.
<table>
<tr>
<td colspan="3" class="bgr_top"/>
</tr>
<tr>
<td class="bgr_left" />
<td>Content content content</td>
<td class="bgr_bottom" />
</tr>
<tr>
<td colspan="3" class="bgr_bottom"/>
</tr>
</table>
Dynamic div
With the help of jQuery, we can emit semantically correct HTML but also create the desired rendering in web browsers. Untested sample:
<p class="bgr">Content content content</p>
<script type="text/javascript">
$('.bgr').each(function(i,el){
$('<div class="bgr_left"/>').height($(this).height()+'px').appendTo($(this));
// similar for top, right, and bottom
});
</script>