What causes a css caption to overlay another image in this table? - html

I have this css caption effect:
.cell {
position: relative;
width: 180px;
height: 180px;
}
.caption {} .cell .caption {
opacity: 0;
text-decoration-color: gray;
text-align: center;
background: #eaeaea;
position: absolute;
font-weight: bold;
width: 180px;
height: 180px;
}
.cell:hover .caption {
box-shadow: 0 5px 2px #777;
cursor: pointer;
opacity: 0.7;
}
<table style="text-align: left; width: 100%;" border="0" cellpadding="0" cellspacing="0">
<c:forEach var="product" items="${categoryProducts}" varStatus="iter">
<td>
<tbody>
<tr>
<td style="vertical-align: middle; width: 180px; text-align: center; height: 180px;" class="cell">
<a href="product?${product.id}">
<img class="img" alt="" src="${initParam.productImagePath}${product.name}.jpg" />
<div class="caption">
<br>view details</div>
</a>
<br>
</div>
</td>
<td style="vertical-align: middle; width: 140px; text-align: center;">${product.name}
<br>
</td>
<td style="vertical-align: middle; width: 125px; text-align: center;">$ ${product.price}
<br>
</td>
<td style="vertical-align: middle; width: 125px; text-align: center;">
<form action="addToWishlist" method="post">
<br>
<br>
<input name="productId" value="${product.id}" type="hidden">
<input class="submit" value="<fmt:message key='AddToWishlist'/>" type="submit">
</form>
<br>
</td>
<td style="vertical-align: middle; width: 123px; text-align: center;">
<form action="addToCart" method="post">
<br>
<br>
<input name="productId" value="${product.id}" type="hidden">
<input class="submit" value="<fmt:message key='AddToCart'/>" type="submit">
</form>
<br>
</td>
</tr>
</tbody>
</c:forEach>
</table>
The code in itself works perfectly fine. The caption shows as expected. The only thing tho, when there's an image inside of the cell, there is a display problem when mouse hover the image as shown from my local browser run from the IDE:
The caption overlays the next cell... What could cause this? I tried to play around with the .img and the .caption but cannot seem to find a solution...
Here the full image overlay caption effect i'm trying to accomplish:
http://www.corelangs.com/css/box/caption.html

So the problem in your screenshot is the caption of the bottom image overlaying on top of the first image? Not sure I understand this correctly, but if so there are three simple solutions I can think about:
Increase the margin between your images / rows
On :hover, increase margin, although that could be poor UX
Increase opacity from 0.7 to 1 so it overlays, but you cannot see the first cell through it

Related

How can I align this submit button using CSS

I am new to CSS, and I am writting a web page with a form that has submit button, but I am not able to align well the submit button within the form
this is what I get with this: enter image description here
I don know how can I fix this, so any help is very appreciated.
h1 {
text-align: center;
color: blue;
}
body {
background-color: #1AD5EA;
text-align: center;
}
form {
display: inline-block;
text-align: center;
}
td {
/* text-align: center; */
font-weight: bold;
}
input[type=submit] {
padding: 5px 55px;
border: 5 none;
border-radius: 15px;
text-align: center;
}
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="estilo.css">
<title>Nuevo cliente</title>
</head>
<body>
<h1>Introduzca los datos del nuevo cliente</h1>
<br/>
<form action="procesar_form.php" method="post">
<table>
<tr>
<td>Nombre</td>
<td>
<input type="text" name="nombre">
</td>
</tr>
<tr>
<td>Direcci&oacuten</td>
<td>
<input type="text" name="direccion">
</td>
</tr>
<tr>
<td>Tel</td>
<td>
<input type="text" name="tel">
</td>
</tr>
<tr>
<td>
<br>
<br>
<input align="center" type="submit" value="Enviar">
</td>
</tr>
</table>
</form>
</body>
</html>
If you want the button to be aligned to the right, you can set the parent td for the submit button to colspan="2" so that the cell will span both columns in your table, and assign text-align: right;
h1 {
text-align: center;
color: blue;
}
body {
background-color: #1AD5EA;
text-align: center;
}
form {
display: inline-block;
text-align: center;
}
td {
/* text-align: center; */
font-weight: bold;
}
input[type=submit] {
padding:5px 55px;
border:5 none;
border-radius: 15px;
text-align:center;
}
.submit {
text-align: right;
}
<html>
<head>
<link rel="stylesheet" type="text/css" href="estilo.css">
<title>Nuevo cliente</title>
</head>
<body>
<h1>Introduzca los datos del nuevo cliente</h1>
<br/>
<form action="procesar_form.php" method="post">
<table>
<tr>
<td>Nombre</td>
<td><input type="text" name="nombre"></td>
</tr>
<tr>
<td>Direcci&oacuten</td>
<td><input type="text" name="direccion"></td>
</tr>
<tr>
<td>Tel</td>
<td><input type="text" name="tel"></td>
</tr>
<tr>
<td colspan="2" class="submit">
<input align="center" type="submit" value="Enviar">
</td>
</tr>
</table>
</form>
</body>
</html>
Since you are using a table to handle your formatting, I don't think what you're looking for needs to be a CSS answer.
In your case, if you are trying to align your button to be below the text input boxes, then you need to create a blank td in your last tr to fill the gap and align the next td that contains your button on the right.
<tr>
<td>
</td>
<td>
<br><br>
<input align="center" type="submit" value="Enviar">
</td>
</tr>
For a CSS-only solution, the easiest next step would be to remove all table references and rely on CSS for positioning of all elements.
Assuming that you want the button to go in the center:
You want to add colspan="2"
in the td which holds you submit button
Please try to avoid using table to position elements as that will never give you full control over your positioning and it is somewhat deprecated.
Try this.
CSS:
h1 {
text-align: center;
color: blue;
}
body {
background-color: #1AD5EA;
text-align: center;
width:100%;
}
form {
display: inline-block;
text-align: center;
}
td {
/* text-align: center; */
font-weight: bold;
}
input[type=submit] {
padding:5px 55px;
border:5 none;
border-radius: 15px;
margin:0 auto;
}
HTML;
<form action="procesar_form.php" method="post">
<table>
<tr>
<td>Nombre</td>
<td><input type="text" name="nombre"></td>
</tr>
<tr>
<td>Direcci&oacuten</td>
<td><input type="text" name="direccion"></td>
</tr>
<tr>
<td>Tel</td>
<td><input type="text" name="tel"></td>
</tr>
<tr>
</table>
<div> <input type="submit" value="Enviar" ></div>
</form>

Why is my CSS not cooperating?

Ok, so maybe I'm slightly losing my mind but I'm trying to recreate a homepage that incorporates 2 background images into my CSS. I'm attempting to use one as a top image and one as a bottom image, and in the middle is a table that has links and images. However, for some reason, I'm having difficulty with pulling it all together to make it look like one smooth image.
For example, my container class (as shown below) only puts a border around the topBox class and not the entire container div. I want all 3 divs to have one border around it (coming from the container class) so that it looks as if its one image. Here is my HTML and CSS.
What am I doing wrong? Thanks in advance for any assistance!
#Container {
float:left;
width: inherit;
height: 400px;
margin-left: auto;
margin-right: auto;
border:1px solid #000000;
}
.boxTop {
position: relative;
left: 100;
top: 100;
width: inherit;
height: 95px;
background-image: url(http://ejgh.org/templates/ejgh/images/HL_logo.jpg);
background-repeat: no-repeat;
/*place background image css code here and remove line above*/
background-position: left 0px top 0px;
background-size: 300px;
}
.box {
position: relative;
left: 100;
top: 100;
width: 350px;
height: 550px;
border:0px solid #000000;
}
.boxBtm {
position: relative;
left: 100;
top: 100;
width: inherit;
height: 95px;
background-image: url(http://ejgh.org/templates/ejgh/images/healthyLifestyles_bottom.gif);
/*place background image css code here and remove line above*/
background-repeat: no-repeat;
background-position: left 0px bottom 0px;
background-size: 300px;
}
<div id="Container">
<div class="boxTop"></div>
<div class="box"><table width="300px">
<tbody>
<tr>
<td>
<table cellspacing="0" cellpadding="6">
<tbody>
<tr>
<td valign="top"><img style="border-width: 0px;" src="http://ejgh.org/images/stories/template/healthylifestyles/apple.jpg" alt="Image of Apple and Weights for homepage" width="86" height="86" /></td>
<td valign="top">
<h3>Become a Member</h3>
<p>Join Healthy Lifestyles and enjoy the benefits of membership.</p>
</td>
</tr>
<tr>
<td valign="top"><img style="border-width: 0px;" src="http://ejgh.org/images/stories/template/healthylifestyles/elderlycouple.jpg" alt="Image of elderly couple at hospital in New Orleans Louisiana" width="86" height="83" /></td>
<td valign="top">
<h3>Classes & Support</h3>
<p>Learn more about the classes, support groups, and health screenings we offer.</p>
</td>
</tr>
<tr>
<td valign="top"><img style="border-width: 0px;" src="http://ejgh.org/images/stories/template/healthylifestyles/tvspot.jpg" alt="Image of Liz Delsa Healthy Lifestyles Host" width="86" height="70" /></td>
<td valign="top">
<h3>Watch the TV Segment</h3>
<p>Watch Healthy Lifestyles TV segments as seen on WWL-TV.</p>
</td>
</tr>
<tr>
<td valign="top"><img src="http://ejgh.org/images/stories/yourhealthimages/healthylifestyles/MagazineCovers/summer2016.jpg" alt="Summer 2016 Healthy Lifestyles Cover" width="86" height="100" /></td>
<td valign="top">
<h3>Read the Magazine</h3>
<p>Read the latest Healthy Lifestyles Magazine as included in the Times-Picayune newspaper.</p>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table></div>
<div class="boxBtm"></div>
</div>
Very simple answer, just remove the hight of the id #Container and it'll work. I hope this is what you where looking for ;)
You have set a specific height on your container, so your border is only going to be that height. If you set the height to 750 pixels, it is going to work.
#Container {
float: left;
width: inherit;
height: 750px;
margin-left: auto;
margin-right: auto;
border: 1px solid #000000;
}
.boxTop {
position: relative;
left: 100;
top: 100;
width: inherit;
height: 95px;
background-image: url(http://ejgh.org/templates/ejgh/images/HL_logo.jpg);
background-repeat: no-repeat;
/*place background image css code here and remove line above*/
background-position: left 0px top 0px;
background-size: 300px;
}
.box {
position: relative;
left: 100;
top: 100;
width: 350px;
height: 550px;
border: 0px solid #000000;
}
.boxBtm {
position: relative;
left: 100;
top: 100;
width: inherit;
height: 95px;
background-image: url(http://ejgh.org/templates/ejgh/images/healthyLifestyles_bottom.gif);
/*place background image css code here and remove line above*/
background-repeat: no-repeat;
background-position: left 0px bottom 0px;
background-size: 300px;
}
<div id="Container">
<div class="boxTop"></div>
<div class="box">
<table width="300px">
<tbody>
<tr>
<td>
<table cellspacing="0" cellpadding="6">
<tbody>
<tr>
<td valign="top">
<a href="http://ejgh.org/your-health/healthy-lifestyles/become-a-member-sp-1672965733">
<img style="border-width: 0px;" src="http://ejgh.org/images/stories/template/healthylifestyles/apple.jpg" alt="Image of Apple and Weights for homepage" width="86" height="86" />
</a>
</td>
<td valign="top">
<h3>Become a Member</h3>
<p>Join Healthy Lifestyles and enjoy the benefits of membership.</p>
</td>
</tr>
<tr>
<td valign="top">
<a href="/component/wrapper/?Itemid=203">
<img style="border-width: 0px;" src="http://ejgh.org/images/stories/template/healthylifestyles/elderlycouple.jpg" alt="Image of elderly couple at hospital in New Orleans Louisiana" width="86" height="83" />
</a>
</td>
<td valign="top">
<h3>Classes & Support</h3>
<p>Learn more about the classes, support groups, and health screenings we offer.</p>
</td>
</tr>
<tr>
<td valign="top">
<a href="/component/hwdvideoshare/?task=viewcategory&Itemid=166&cat_id=5">
<img style="border-width: 0px;" src="http://ejgh.org/images/stories/template/healthylifestyles/tvspot.jpg" alt="Image of Liz Delsa Healthy Lifestyles Host" width="86" height="70" />
</a>
</td>
<td valign="top">
<h3>Watch the TV Segment</h3>
<p>Watch Healthy Lifestyles TV segments as seen on WWL-TV.</p>
</td>
</tr>
<tr>
<td valign="top">
<a href="/your-health/healthy-lifestyles/healthy-lifestyles-magazine">
<img src="http://ejgh.org/images/stories/yourhealthimages/healthylifestyles/MagazineCovers/summer2016.jpg" alt="Summer 2016 Healthy Lifestyles Cover" width="86" height="100" />
</a>
</td>
<td valign="top">
<h3>Read the Magazine</h3>
<p>Read the latest Healthy Lifestyles Magazine as included in the Times-Picayune newspaper.</p>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</div>
<div class="boxBtm"></div>
</div>
This can be a lot simpler - you only need one wrapper div, not three. (You also shouldn't be using a table for layout purposes, but that's a whole other subject. For now, this'll work if you drop your table in where the content p tags are.)
Here's how to get roughly the visuals you want with a lot less code:
.box {
width: 300px;
border: 1px solid;
border-radius: 0 0 9px 9px;
/* You can specify multiple background images like this: */
background-image: url(http://ejgh.org/templates/ejgh/images/HL_logo.jpg), url(http://ejgh.org/templates/ejgh/images/healthyLifestyles_bottom.gif);
background-size: 100% auto;
background-repeat: no-repeat;
/* first position goes with the first image url and vice versa */
background-position: top, bottom;
/* 130px padding on top to create room for the "lifestyles" logo
20px on the sides for breathing room
50px at the bottom to create room for the green gradient
tweak these values till you like the spacing */
padding: 130px 20px 50px;
}
<div class="box">
<p>content</p>
<p>content</p>
<p>content</p>
</div>

Apply CSS same as legend tag

I want to create a border around my html component. HTML legend element can be used but i want to use it out of the form.
HTML Legend: http://www.w3schools.com/tags/tryit.asp?filename=tryhtml_fieldset
I tried but there is an issue title and border. Below is the jsfiddle for the same.
.temp {
border: 1px solid #999;
margin-top: 20px;
padding: 20px;
position: relative;
}
http://jsfiddle.net/alpeshprajapati/a6a93fg9/1/
How can i achieve output same as legend ? Thanks.
You are pretty much there. The last step to make your markup look like a legend would be to add a background-color to the span which matches the background-color of .temp and the element that contains it. This ensures that the border or .temp does not show behind the text (as background-color is transparent by default).
.temp > span {
background-color: white;
font-size: 21px;
left: 2%;
position: absolute;
top: -15px;
}
.temp {
border: 1px solid #999;
margin-top: 20px;
padding: 20px;
position: relative;
}
<div class="temp">
<span>Permissions</span>
<table class="table cs-table-no-bordered table-striped">
<thead>
<tr>
<th>Modules</th>
<th class="text-center">Edit</th>
<th class="text-center">Delete</th>
<th class="text-center">View</th>
<th class="text-center">All</th>
</tr>
</thead>
<tbody>
<tr>
<td>M1</td>
<td class="text-center">
<input type="checkbox" />
</td>
<td class="text-center">
<input type="checkbox" />
</td>
<td class="text-center">
<input type="checkbox" />
</td>
<td class="text-center">
<input type="checkbox" />
</td>
</tr>
</tbody>
</table>
</div>

Removing top padding from table cell div

I have the same issue.
.mainDiv {
border-spacing: 15px;
}
.formDiv {
width: 300px;
background-color: #F5F6CE;
padding: 10px;
margin-left: 20px;
display: table-cell;
vertical-align: top;
}
.resultDiv {
background-color: #F5F6CE;
padding: 20px;
box-shadow: 5px 5px 5px #888888;
margin-left: 20px;
display: table-cell;
width: 100%;
}
Now, I want to add <h1> to formDiv which results in:
I want the company registration to be aligned to top.
I found many threads giving answer:
vertical-align: top;
but it's not working for me. Please help.
HTML is:
<div class="mainDiv">
<div class="formDiv" align="center">
<h1 align="center">Company Registration</h1>
<form id="compReg" onsubmit="SaveData();return false;">
<Table align="center" cellspacing="5px">
<tr>
<td>
<Input id="txtEmail" type="email" class="text" placeholder="Contact Email" />
</td>
</tr>
<!-- other input types -->
<tr>
<td>
<Input type="submit" value="Submit" />
<Input type="reset"/>
</td>
</tr>
</table>
</form>
</div>
<div class="resultDiv" id="result">
<div align="right">
<input type="button" onclick="clearData()" value="Clear" />
<br>
<br>
</div>
<table class="dataTable" width="300">
<thead>
<th width="20px">Id</th>
<th width="250px">Email</th>
<!-- other headers -->
<th width="50px">Color</th>
</thead>
<tbody id="tbody">
</tbody>
</table>
</div>
</div>
check JSFiddle I want the "problem" h1 to be aligned at top of left div.
h1 tag has default margin. Try to set it to 0px.
h1{
margin:0px;
}
Try resetting the default table padding and margin values
#yourtable {
margin: 0;
padding: 0;
}
As from my understanding if you are using table and trying to solve table cell spacing issue. try to make zero cell-spacing and cell-padding.
<table cellpadding="0" cellspacing="0">
CSS to H1 spacing
table h1{ margin:0; padding:0; }
JSFIDDLE DEMO
You mean this? Please post your HTML-Markup next time!
h1 { margin:0; background: blue; }
.formDiv {
width: 300px;
background-color: #F5F6CE;
margin-left: 20px;
padding: 0 10px 10px 10px;
display: table-cell;
}
<div class="wrapper">
<div class="formDiv">
<h1>Lorem</h1>
<p>ipsum dolor</p>
<input name="test" type="text">
</div>
</div>
Look at your fiddle: http://jsfiddle.net/xsmzLb3g/2/
You have to change the margin/padding of the h1 and div.

input field width is not what I set it to be, misaligned. Additional border in input

http://jsfiddle.net/HnnHf/1/
Trying to understand what I do wrong. Plain table, I want input boxes to fill cells evenly. On first row you see 2 inputs and second row has one input spanned across cells.
Their right sides don't match. Why? When I run inspector it shows additional pixels?
Part of my HTML:
<div style="width: 1000px; margin-left: auto; margin-right: auto; padding-left: 20px; padding-top: 10px;">
<table>
<tr>
<td style="width: 80px;"><label>From </label></td>
<td style="width: 120px;">
<input type="text" class="fill-space" />
</td>
<td style="width: 80px;"><label>To </label></td>
<td style="width: 120px;">
<input type="text" class="fill-space" />
</td>
<td style="width: 80px;"><label>Sort by </label></td>
<td></td>
</tr>
<tr>
<td colspan="6"> </td>
</tr>
<tr>
<td></td>
<td colspan="3">
<input type="text" class="search" />
</td>
<td></td>
<td>
Refresh button
</td>
</tr>
</table>
</div>
Style:
td label {
width: 100%;
color: #F1F1F1;
text-align: right;
vertical-align: central;
}
input.fill-space {
width: 100%;
}
input.search {
width: 100%;
background-image: url("/images/Search.png");
background-position: right center;
background-repeat: no-repeat;
}
</style>
My live site misalignment:
Also, why do I get this another border inside input if I set background?
Working fiddle: http://jsfiddle.net/ghUEw/
Default padding and margins for table elements differ in different browsers.
So you'd better use a CSS reset on table elements.
table * {
margin: 0;
padding: 0;
}
Then, comes the border-collapse property. It determines whether the table borders are collapsed into a single border or rendered individually, let's say for neighboring table cells. You need to set it as following to make them collapsed since you have different number of cells per table row.
table {
border-collapse: collapse;
}
Then, you need to set the borders of the inputs in your table if you want them look the same.
table input {
border: 1px solid #aaa;
}
If you don't want any borders to appear, replace it with border: none;
Then, in your CSS, for the labels to appear the way you want, you can apply float:right; (also corrected vertical-align: middle;)
td label {
width: 100%;
color: #F1F1F1;
text-align: right;
vertical-align: middle;
float:right;
}