I'm trying to use a table as a replacement for an image map so that it can be responsive, but for some reason, after setting the table's height to 100%, it still goes past the body, and I can't figure out why.
CSS and HTML:
body,
html {
padding:0;
margin:0;
width:100%;
height:100%;
}
body {
background-color:black;
}
html {
background-color:white;
}
table {
border-spacing:0;
border-collapse: collapse;
height:100%;
margin:0 auto;
}
td {
margin:0;
padding:0;
height:100%;
}
tr {
height:100%;
}
<table>
<tr data-name="row1">
<td data-name="pic1">
<a class="openBox" data-source="split/A1-4096-0171.mp4">
<img src="thumb/A1-4096-0171.png">
</a>
</td>
<td data-name="pic2">
<a class="openBox" data-source="split/B1-4096-0171.mp4">
<img src="thumb/B1-4096-0171.png">
</a>
</td>
</tr>
<tr data-name="row2">
<td data-name="pic3">
<a class="openBox" data-source="split/A2-4096-0171.mp4">
<img src="thumb/A2-4096-0171.png">
</a>
</td>
<td data-name="pic4">
<a class="openBox" data-source="split/B2-4096-0171.mp4">
<img src="thumb/B2-4096-0171.png">
</a>
</td>
</tr>
<tr data-name="row3">
<td data-name="pic5">
<a class="openBox" data-source="split/A3-4096-0171.mp4">
<img src="thumb/A3-4096-0171.png">
</a>
</td>
<td data-name="pic6">
<a class="openBox" data-source="split/B3-4096-0171.mp4">
<img src="thumb/B3-4096-0171.png">
</a>
</td>
</tr>
<tr data-name="row4">
<td data-name="pic7">
<a class="openBox" data-source="split/A4-4096-0171.mp4">
<img src="thumb/A4-4096-0171.png">
</a>
</td>
<td data-name="pic8">
<a class="openBox" data-source="split/B4-4096-0171.mp4">
<img src="thumb/B4-4096-0171.png">
</a>
</td>
</tr>
</table>
Screenshot of the issue:
The black is the body background is the body tag, while the white is the html tag, so the table is, for some reason, going outside the body going by the way it looks. It should be no taller than the window based on my CSS, correct?
Related
I have a table on my site. When I add position:fixed to the table, the cells of the table suddenly stretch across the entire height of the page, even though they have a set height.
as you can see in the code below, each tr has a set height value, but it is ignored when I add position:fixed to the table, and instead, the cells get the height of the entire page, and prevent me from accessing the content of the website.
any help on how to fix this, while still keeping the position:fixed attribute, would be appreciated.
.center {
margin:0 auto;
}
a{
text-decoration:none;
color:red;
}
table{
text-align:center;
width:30%;
left:25%;
/*font-size:larger;*/
}
body{
background-color:midnightblue;
color:snow;
white-space:nowrap;
}
.Error{
color:red;
}
.divSargel{
width:initial;
background-color:snow;
border: solid;
border-color: #000080;
float: left;
margin-left: 0.3%;
color: red;
font-size:x-large;
font-family:monospace;
border-radius: 20px;
text-align: center;
width:100%;
}
.divSargel:hover {
background-color: blue;
transition: linear 0.5s;
}
<table id="navbar" border="1" style="right:0px;left:0px;border-style: solid;border-color:black;margin:0 auto;max-width:999999px; width:100%; height: 100%; background-image: none;">
<tr>
<td colspan="5" style="background-image: url('/Pics/videogames2.jpg'); height:100px; background-repeat: no-repeat; background-size:100% 100%">
</td>
</tr>
<tr style="height:50px">
<td style="border-color: #000000; background-color: #000000; color: #FFFFFF;">
<asp:TextBox ID="txtClock" style="text-align:center" runat="server" width="90%" ReadOnly="true"></asp:TextBox>
</td>
<td style="border-color: #000000; color: #FFFFFF; background-color: #000000">
<asp:TextBox ID="txtPeopleCount" style="text-align:center" runat="server" Width="90%" ReadOnly="true"></asp:TextBox>
</td>
<td style="width:50%;border:medium solid #000080; background-color: #000000;">
<table border="1" style="border-color:snow;width:100%">
<%if (Session["UserName"] == null)
{ %>
<tr>
<td class="textCenter">
<a href="Main.aspx" class="divSargel">
Main
</a>
</td>
<td class="textCenter">
<a href="ShopProducts.aspx" class="divSargel">
Shop
</a>
</td>
</tr>
<%} %>
<%if (Session["UserName"] != null && Session["UserAdmin"] == null)
{ %>
<tr>
<td class="textCenter">
<a href="Main.aspx" class="divSargel">
Main
</a>
</td>
<td class="textCenter" >
<a href="ShowUsers.aspx" class="divSargel">
Show Users
</a>
</td>
<td class="textCenter">
<a href="ShopProducts.aspx" class="divSargel">
Shop
</a>
</td>
<td class="textCenter">
<a href="ShoppingCart.aspx" class="divSargel">
View Cart
</a>
</td>
</tr>
<tr>
<td class="textCenter">
<a href="ShowBank.aspx" class="divSargel">
View Bank
</a>
</td>
<td class="textCenter">
<a href="ShowCreditCards.aspx" class="divSargel">
View credit cards
</a>
</td>
<td class="textCenter">
<a href="ShowOrders.aspx" class="divSargel">
View Orders
</a>
</td>
<td class="textCenter">
<a href="ContactUs.aspx" class="divSargel">
Contact us
</a>
</td>
</tr>
<%} %>
<%if (Session["UserAdmin"] != null)
{ %>
<tr>
<td class="textCenter">
<a href="Main.aspx" class="divSargel">
Main
</a>
</td>
<td class="textCenter" >
<a href="ShowUsers.aspx" class="divSargel">
Show Users
</a>
</td>
<td class="textCenter">
<a href="ShopProducts.aspx" class="divSargel">
Shop
</a>
</td>
<td class="textCenter">
<a href="ShoppingCart.aspx" class="divSargel">
View Cart
</a>
</td>
</tr>
<tr>
<td class="textCenter">
<a href="ShowBank.aspx" class="divSargel">
View Bank
</a>
</td>
<td class="textCenter">
<a href="ShowCreditCards.aspx" class="divSargel">
View credit cards
</a>
</td>
<td class="textCenter">
<a href="ShowOrders.aspx" class="divSargel">
View Orders
</a>
</td>
<td class="textCenter">
<a href="AdminPage.aspx" class="divSargel">
Admin actions
</a>
</td>
</tr>
<%} %></table>
</td>
<%if (Session["UserName"] == null)
{ %>
Try setting the height of the table as desired and mark it as important like
table{
height : 150px !important;
}
Managed to find the problem. for some reason I had a height:100% on the table itself, and so even though the rows had specified heights, upon adding position:fixed the table stretched across the screen.
I want to split screen to two area left and right,in right segment show a image and in right segment show textbox,for that purpose write this html code:
<table style="width:100%">
<tr>
<td style="width:50%;height:100%;" align="center">
<img src="../Content/45.png" style="display:block;height:100%;width:100%;" />
</td>
<td style="width:50%;">
behzad
</td>
</tr>
</table>
but when i run the html page ,image not fit to the table column height,and i must scroll the browser to see all of the page,i want just fit to the screen height,my out put i this :
Use viewport units vh/vw, and to keep aspect ratio on the image, set the style on the image to display:block;max-width:50vw;max-height:100vh
html, body {
margin: 0;
}
table {
border-collapse: collapse;
}
td {
padding: 0;
vertical-align: top;
}
<table style="width:100vw">
<tr>
<td style="width:50vw;height:100vh;" align="center">
<img src="http://lorempixel.com/600/600/animals" style="display:block;max-width:50vw;max-height:100vh" />
</td>
<td style="width:50vh;">
behzad
</td>
</tr>
</table>
in this case you'd better use background-image instead of <img> to avoid stretching
check the following demo
html,body{
height:100%;
}
table{
height:100%;
}
<table style="width:100%">
<tr>
<td style="width:50%;height:100%;background-image:url(http://placehold.it/600x600)" align="center">
</td>
<td style="width:50%;">
behzad
</td>
</tr>
</table>
emphasized text
instead of this section
<img src="../Content/45.png" style="display:block;height:100%;width:100%;" />
try this section
<img src="../Content/45.png" height="50%" />
I hope it works
I am having trouble reducing the height of the table cells in rows 1 and 2. I tried setting the table rows to 100 pixels within html, but when I do that table cells below the row grow larger as if compensating for the missing space. I do not see this happening in the fiddle below, but I am having this problem in Chrome. I would appreciate any help. The relevant code is below, and the full page is in the fiddle.
https://jsfiddle.net/9qLg7c31/2/
HTML:
Resume Page
<br>
<table class="no-spacing">
<tr style="height:100px">
<td>
Northwestern University
</td>
<td>
Class of 2016
</td>
<td>
Bachelors of Science in Journalism
</td>
<td style="text-indent: 10px">
Integrated Marketing Certificate
</td>
</tr>
<tr>
<td>
Field
</td>
<td>
2012
</td>
<td>
2013
</td>
<td>
2014
</td>
<td>
2015
</td>
<td>
2016
</td>
</tr>
<tr>
<td>Content Marketing</td>
<td style="background-color:white">
<div class="dropdown";>
<img src="http://st.hzcdn.com/fimgs/5f33bbc80182569c_3779-w173-h173-b1-p0--whatasteele.jpg">
<div class="dropdown-content">
</div>
</div>
</td>
<td style="background-color: white">
</td>
<td>
</td>
<td style="background-color: white">
<div class="dropdown">
<img src="http://www.reelnreel.com/wp-content/uploads/2015/01/Wochit.png">
<div class="dropdown-content">
</div>
</div>
</td>
<td style="background-color:white">
</td>
</tr>
<tr>
<td>
Multimedia Journalism
</td>
<td>
</td>
<td>
</td>
<td style="background-color: blue">
<div class="dropdown">
<img src="http://www.complaintsboard.com/thumb.php?src=chicago-tribune.jpg&wmax=900&hmax=900&quality=90&nocrop=1&bname=120767">
<div class="dropdown-content">
</div>
</div>
</td>
<td style="background-color: black">
<div class="dropdown">
<div class="dropdown-content">
<img src="http://onekreate.com/wp-content/uploads/2014/04/40_Inc_Magazine.jpg">
</div>
</div>
</td>
<td>
</td>
</tr>
<tr>
<td>Volunteer Work</td>
<td style="background-color: purple">
<div class="dropdown">
<div class="dropdown-content">
<img src="https://pbs.twimg.com/profile_images/570772503543291904/uYixut-M.jpeg" style="width:100px; height:100px">
</div>
</td>
<td style="background-color: purple">
</td>
<td style="background-color: purple">
</td>
<td>
</td>
<td>
</tr>
</table>
CSS:
#resume {
width: 100%;
height: 150%;
background-color: rgb(0,300,200);
margin-bottom:0px;
z-index:0;
}
#resume table{
background-color: rgb(0,200,200);
margin-left: 2.5%;
width:95%;
height:100%;
padding-bottom:10px;
border-radius: 20px;
}
#resume table ul{
color: rgb(0,300,200);
font-size:20px;
}
.no-spacing {
border-spacing:0; /* Removes the cell spacing via CSS */
border-collapse: collapse; /* Optional - if you don't want to have double border where cells touch */
}
.dropdown {
position: relative;
display: inline-block;
}
.dropdown-content{
display: hidden;
}
.dropdown:hover .dropdown-content{
display:block;
position: relative;
width:300px;
}
#resume table th{
padding:15px 0 15px 0;
}
#resume table img{
width:150px;
height:100px;
}
#resume table tr:nth-child(3), #resume table tr:nth-child(4), #resume table tr:nth-child(5){
height:200px;
}
I'm trying to make an html mail so I need to use inline CSS. The problem is that I can't figure out why the cell height I set doesn't display as I intended. I've set the % height of the cells like I would them to be, but the result isn't as I expected.
The code is this and as you can see the result is not like I intended because I've set 15% for the header but in the result is obviously not 15% and no matter the value it does not change the result. The same thing happens with the other td:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset="UTF-8">
<title></title>
</head>
<body>
<table style="table-layout:fixed; width:56%; height:100%;" border="1" bordercolor=black align=center>
<tr>
<th colspan="2" style="height:15%; width:100%;" >
<a href="http://www/">
<img src="D:\web_mail\EN_TW1-EE_3D-Logo.pn" width="56%" alt="Header"/> </a>
</th>
</tr>
<tr>
<td style="border-right-width: 0.5px; border-bottom-width: 1px; height:10%; width:50%;" >
<img src="D:\web_mail\Halo_4_-_Master_Chief.pn" width="100%" alt="Patrik" />
</td>
<td style="border-left-width: 0.5px; border-bottom-width: 1px; height:10%; width:50%;" >
<img src="D:\web_mail\08e7d7c88c962186ed557780ab41c628-d65czl9.jp" width="100%" alt="Alberta" />
</td>
</tr>
<tr>
<td colspan="2" style="height:60%; width:100%;" >
<img src="D:\web_mail\08e7d7c88c962186ed557780ab41c628-d65czl9.jp" width="100%" alt="Igor"/>
</td>
</tr>
<tr>
<th colspan="2" style="height:15%; width:100%;" >
<img src="D:\web_mail\08e7d7c88c962186ed557780ab41c628-d65czl9.jp" width="56%" alt="Footer"/>
</th>
</tr>
</table>
</body>
</html>
I hope you can help me.
To have the image to stretch to the same height and width as the containing boxes, simply add a 100% width and a height equal to the row it is in:
http://jsfiddle.net/j2bcc24o/4/
If you just want the width, go for:
http://jsfiddle.net/j2bcc24o/3/
<td style="border-right-width: 0.5px; border-bottom-width: 1px; height:10%; width:50%;">
<img src="image.png" width="100%" height="10%" alt="Patrik" />
</td>
And also don't forget to set html and body to 100% height and width as well as 0 padding and margin:
html, body {
height: 100%;
width: 100%;
margin: 0;
padding: 0;
}
i am not able to understand your problem properly,
assign class to td and set the height
<td class="classname">
</td>
.className{
height:20%;
background:red;
}
Try the below code
let me know if you need any help.
<html>
<head>
<style>
html,body{
height:100%;
margin:0 auto;
}
table{
table-layout:fixed;
width:56%;
height:100%;
border:1px solid #000;
text-align:center;
margin:0 auto;
}
table th{
height:15%;
width:100%;
}
.className{
height:20%;
background:red;
}
td{
height:50%;
border:1px solid #000;
background:#000;
width:100%;
}
</style>
</head>
<body>
<table >
<tr>
<th colspan="2" >
<img src="D:\web_mail\EN_TW1-EE_3D-Logo.pn" width="56%" alt="Header"/>
</th>
</tr>
<tr>
<td >
<img src="D:\web_mail\Halo_4_-_Master_Chief.pn" width="100%" alt="Patrik" />
</td>
<td >
<img src="D:\web_mail\08e7d7c88c962186ed557780ab41c628-d65czl9.jp" width="100%" alt="Alberta" />
</td>
</tr>
<tr>
<td colspan="2" class="className" >
<img src="D:\web_mail\08e7d7c88c962186ed557780ab41c628-d65czl9.jp" width="100%" alt="Igor"/>
</td>
</tr>
<tr>
<th colspan="2" >
<img src="D:\web_mail\08e7d7c88c962186ed557780ab41c628-d65czl9.jp" width="56%" alt="Footer"/>
</th>
</tr>
</table>
</body>
</html>
Defining height in percentage will not work with td/div, specially for the mailers, need to assign pixel values only.
This is my simple webpage :-
<html>
<head>
<style type="text/css">
.body{
max-width:3072px;
min-width:3072px;
margin:0px auto;
background: url('Stripes.png') no-repeat #293231;
background-attachment:fixed;
background-position:0% 25%;
}
.back{
z:index:0;
}
</style>
</head>
<body class="body">
<table cellpadding="0" cellspacing="0">
<tr>
<td>
<img src='Main.jpg' class="back"/>
</td>
<td>
<img src='Page2.jpg'/>
</td>
<td>
<img src='Page3.jpg'/>
</td>
</tr>
<tr>
<td>
<img src='MiddleLeft.png'/>
</td>
<td>
<img src='MiddleMiddle.png'/>
</td>
<td>
<img src='MiddleRight.png'/>
</td>
</tr>
<tr>
<td>
<img src='footer.jpg'/>
</td>
<td>
<img src='footer.jpg'/>
</td>
<td>
<img src='footer.jpg'/>
</td>
</tr>
</table>
</body>
</html>
Problem here is due to my large monitor the footer doesn't appear at the bottom of the monitor. It appears somewhere in the middle. How do i ensure that footer appears only at the bottom of the screen irrespective of the size of the screen?
Have a look at:
A Bulletproof Sticky Footer, Woohoo!