html css float:right with img is not working fine - html

HTML
<table class='titleStatus' id='title'>
<tr>
<td class='lefttop'></td>
<td class='bar'>Punch Data
<img class='minMaxClose' src='images/close.png'>
<img class='minMaxClose' src='images/max.png'>
<img class='minMaxClose' src='images/minimize.png'>
<img class='minMaxClose' src='images/setting.png'></td>
<td class='righttop'></td>
</tr>
</table>
CSS
.minMaxClose{float: right;}
OutPut at IE
Whereas i need output like on Firefox

apply float:left to all images first and then apply float:right to your container containing images
.bar img{
float:left;//for shifting alongside
}
.bar{
float:right;//for shifting entire division to right side
}

http://jsfiddle.net/Am34U/3/ give bar a width of 800px or something, and say you put punch inside a span and give it a span of 300px and float left, and give the span that contains the images a span of 500px and float left too.
HTML
<table class='titleStatus' id='title'>
<tr>
<td class='lefttop'></td>
<td class='bar'>
<span id="punch">Punch Data</span>
<span id="close">
<img class='minMaxClose' src='images/close.png'>
<img class='minMaxClose' src='images/max.png'>
<img class='minMaxClose' src='images/minimize.png'>
<img class='minMaxClose' src='images/setting.png'>
</span>
</td>
<td class='righttop'></td>
</tr>
</table>
CSS
.minMaxClose{
float: right;
}
#close{
background: purple;
width: 400px;
float: left;
}
#punch{
background: orange;
width: 300px;
float: left;
}
.bar{
width: 700px;
background: blue;
}

HTML
<table class='titleStatus' id='title'>
<tr>
<td class='lefttop'></td>
<td class='bar'>Punch Data
<!--[if IE]>
<div class='ico-wrapIE'>
<![endif]-->
<!--[if !IE]>
<div class='ico-wrap'>
<![endif]-->
<img class='minMaxClose' src='images/setting.png'>
<img class='minMaxClose' src='images/minimize.png'>
<img class='minMaxClose' src='images/max.png'>
<img class='minMaxClose' src='images/close.png'>
</div>
</td>
<td class='righttop'></td>
</tr>
</table>
CSS
.ico-wrap{float:right;}
.ico-wrapIE {
position: absolute;
right: 2px;
top: 2px;
}

Related

How do I move a table from right to left using CSS and HTML

I have a table row at the footer which displays images from the database. I want the table row to enter the page from the right and disappear at the left side of the page until all images are displayed. I have used this code for displaying images
app.blade.php
<div class="footer">
<div class="row justify-content-center">
<div class="container">
<div class="">
#foreach($logo as $l)
<!--<div class="footercar" style="margin:6px;">-->
<!-- <img class="" src="https://partners.hotelstore.co.ke/public{{ $l->company_logo }}" style="width:150px; height:100px;">-->
<!--</div>-->
<table class="footercar">
<tr>
<td>
<img class="" src="https://partners.hotelstore.co.ke/public{{ $l->company_logo }}" style="width:150px; height:100px;">
</td>
</tr>
</table>
#endforeach
</div>
</div>
</div>
<div class="mytext">
<p class="footertext">© Copyright <?php //echo date("Y"); ?> Hotel Store Partners</p>
</div>
</div>
app.css
.footer{
position: fixed;
height:150px;
bottom: 0px;
width: 100%;
background-color: #DCDCDC;
text-align: center;
margin-top:-200px;
}
.footercar, table{
background-color:rgb(220,220,220);
animation: moveImage 3s linear infinite;
display:inline;
left: -350px;
}
.footerminicar{
padding: 2px 16px;
}
#keyframes moveImage {
100% {
transform: translateX(calc(100vw + 350px));
}
}
.footertext{
font-size:14px;
color:#000000;
}
I have managed to display the images. The CSS does not seem to work. How do I get it to work?
The easiest way is to use html tag marquee
#ImageSilder img{
height: 200px;
width: auto;
object-fit; cover;
}
<table>
<tfoot>
<tr>
<th>
<marquee id="ImageSilder">
<img src="https://img.freepik.com/free-psd/white-frame-mock-up-wall_23-2148374732.jpg?size=664&ext=jpg" />
<img src="https://img.freepik.com/free-psd/let-s-go-travel-man-looking-his-phone-shoulder-shot_23-2148415994.jpg?size=664&ext=jpg" />
<img src="https://img.freepik.com/free-psd/golden-logo-mockup-luxury_145275-32.jpg?size=664&ext=jpg" />
</marquee>
</th>
</tr>
</tfoot>
</table>
I used foreach loop inside the marquee tags
app.blade.php
<table class="footercar">
<tr class="">
<td>
<marquee id="ImageSilder">
#foreach($logo as $l)
<img class="mimg" src="https://partners.hotelstore.co.ke/public{{ $l->company_logo }}" style="width:150px; height:100px;">
#endforeach
</marquee>
</td>
</tr>
</table>
app.css
#ImageSilder, .mimg{
height: 200px;
width: auto;
padding-left:5px;
}

Image not scaling smaller as the resolution decreases

I am using bootstrap. This is my code.
HTML
<div class="choose1 hidden-xl hidden-lg hidden-md hidden-sm">
<div class="container">
<div class="row">
<div class="col-md-12 col-xs-12">
<table width="100%">
<tr>
<td align="center" style="padding:5px;"><img src="img/app_store.png" alt="" style="height:auto; width:220px;" /></td>
</tr>
<tr>
<td align="center" style="padding:5px;"><a href="#" ><img src="img/google_play.png" alt="" style="height:auto; width:220px;" /></a></td>
</tr>
<tr>
<td align="center" style="padding:5px;"><a href="#" ><img src="img/amazon.png" alt="" style="height:auto; width:220px;" /></a></td>
</tr>
</table>
</div>
</div>
</div>
</div>
And CSS:
.choose1 {
background: url('img/slides/1mobile.png') top center no-repeat;
height: 320px;
border: 1px solid red;
}
When I check the image on small screen, the banner does becomes small, instead it slips out of the div. Please check the live site here on small screen. WHat should I do so that the image transforms as much as the div is.
Try This:
.choose1 {
background: url('img/slides/1mobile.png') top center no-repeat;
border: 1px solid red;
background-size: 100% auto;
}

Why is my html table taking up more height than necessary?

I have a table with a bunch of the same image in a single row. The image has a height of 21px but the cells of the table have a rendered height of 25px (in Chrome, Safari, and Firefox).
There's nothing else in the table, and from what I can tell, there are no margins, borders, or padding. So why is my table taller than it needs to be?
Here's an example:
http://jsfiddle.net/q6zy17dz/
And here's a simple example of the table:
<table>
<tbody>
<tr>
<td><img src="http://i.imgur.com/b2f5t2B.png"></td>
<td><img src="http://i.imgur.com/b2f5t2B.png"></td>
<td><img src="http://i.imgur.com/b2f5t2B.png"></td>
<td class="datetime"></td>
<td><img src="http://i.imgur.com/b2f5t2B.png"></td>
<td><img src="http://i.imgur.com/b2f5t2B.png"></td>
<td><img src="http://i.imgur.com/b2f5t2B.png"></td>
</tr>
</tbody>
</table>
Bonus question: Is there a way to recreate this layout without using a table (and also without using floats)?
By default, an image within a table gets the computed display:table-cell property.
You should set img { display: block; }
You can do it entirely without tables.
body {
width: 100%;
height: 100%;
margin: 0px;
padding: 0px;
}
nav {
background-color: skyblue;
position: relative;
text-align: center;
line-height: 22px;
}
.left, .right {
font-size: 0;
position: absolute;
top: 0;
}
.left { left: 0; }
.right { right: 0; }
<nav>
<div class="left">
<img src="http://i.imgur.com/b2f5t2B.png">
<img src="http://i.imgur.com/b2f5t2B.png">
<img src="http://i.imgur.com/b2f5t2B.png">
</div>
<div class="datetime">foo</div>
<div class="right">
<img src="http://i.imgur.com/b2f5t2B.png">
<img src="http://i.imgur.com/b2f5t2B.png">
<img src="http://i.imgur.com/b2f5t2B.png">
</div>
</nav>
It is the line-height property that makes the height of <td> to be 25px. In your example setting a value of 11px or less will make the cells have 21px.
td { line-height:11px;}
Here is jsfiddle.
Because the <img> tag is rendered like an inline element, similarly to letters. There is space below it is for the descenders.
There are few ways to get rid of that space.
Adjust the vertical alignment:
img {vertical-align:top;} /*or*/ img {vertical-align:middle;}
Or, set it as a block element:
img {display:block;}
Or, float it (works in this case, but not recommended):
img {float:left;}
<style type="text/css">
td { border:solid 1px black; margin:0px; padding:0px; }
</style>
<div>
<table>
<tr>
<td><img src="http://i.imgur.com/b2f5t2B.png"></td>
<td><img src="http://i.imgur.com/b2f5t2B.png"></td>
<td><img src="http://i.imgur.com/b2f5t2B.png"></td>
<td class="datetime">foo</td>
<td><img src="http://i.imgur.com/b2f5t2B.png"></td>
<td><img src="http://i.imgur.com/b2f5t2B.png"></td>
<td><img src="http://i.imgur.com/b2f5t2B.png"></td>
</tr>
</table>
</div>
<br>
<div>
<span style="float:left;"><img src="http://i.imgur.com/b2f5t2B.png"></span>
<span style="float:left;"><img src="http://i.imgur.com/b2f5t2B.png"></span>
<span style="float:left;"><img src="http://i.imgur.com/b2f5t2B.png"></span>
<span class="datetime" style="float:left;">foo</span>
<span style="float:left;"><img src="http://i.imgur.com/b2f5t2B.png"></span>
<span style="float:left;"><img src="http://i.imgur.com/b2f5t2B.png"></span>
<span style="float:left;"><img src="http://i.imgur.com/b2f5t2B.png"></span>
</div>

vertical-align image + bottom text

My template :
<td class="image">
<img src="">
<div class="align-bottom">
text
</div>
</td>
<td class="image">
<img src="">
<div class="align-bottom">
text
</div>
</td>
<td class="image">
<img src="">
<div class="align-bottom">
text
</div>
</td>
How do I vertical-middle align the image (the images have different sizes...) and vertical-bottom align the text(different sizes.)
The td height is dynamic.
I'm sorry but position:absolute doesn't work ...the images have different sizes.
What you can do is to have 2 rows in the table.
Row 1 with all the images and Row 2 with the text
for each image add
img {
margin:auto;
}
and for text, align:center.
I think that should do the job.
Use this structure : http://jsfiddle.net/vse8cq5y/
From your given HTML and request I'm assuming this is what you will need to get what you want.
The images should automatically do what you are asking, all you need to do is position absolute the text to the bottom of the td.
By adding padding bottom to the each td, you are allowing space for the text to go, meaning that it will never overlap with your image (regardless of image size).
img {
background-color: red;
display: block;
width:5em;
height:2em;
margin: 0 auto;
}
td {
width:10em;
padding-bottom: 1em;
position: relative;
vertical-align: middle; /*should be default*/
}
.container {
background-color: blue;
display:inline-block;
}
.align-bottom {
position: absolute;
bottom: 0;
left:0;
display: inline;
width: 100%;
text-align: center;
}
<table>
<tr>
<td class="image">
<img src="" style="height: 4em">
<div class="align-bottom">
text
</div>
</td>
<td class="image">
<img src="" style="height: 7em">
<div class="align-bottom">
text
</div>
</td>
<td class="image">
<img src="" style="height: 10em">
<div class="align-bottom">
text
</div>
</td>
</tr>
</table>

Bring element to front using CSS

I can't figure out how to bring images to front using CSS. I've already tried setting z-index to 1000 and position to relative, but it still fails.
Here's example-
#header {
background: url(http://placehold.it/420x160) center top no-repeat;
}
#header-inner {
background: url(http://placekitten.com/150/200) right top no-repeat;
}
.logo-class {
height: 128px;
}
.content {
margin-left: auto;
margin-right: auto;
table-layout: fixed;
border-collapse: collapse;
}
.td-main {
text-align: center;
padding: 80px 10px 80px 10px;
border: 1px solid #A02422;
background: #ABABAB;
}
<body>
<div id="header">
<div id="header-inner">
<table class="content">
<col width="400px" />
<tr>
<td>
<table class="content">
<col width="400px" />
<tr>
<td>
<div class="logo-class"></div>
</td>
</tr>
<tr>
<td id="menu"></td>
</tr>
</table>
<table class="content">
<col width="120px" />
<col width="160px" />
<col width="120px" />
<tr>
<td class="td-main">text</td>
<td class="td-main">text</td>
<td class="td-main">text</td>
</tr>
</table>
</td>
</tr>
</table>
</div>
<!-- header-inner -->
</div>
<!-- header -->
</body>
Add z-index:-1 and position:relative to .content
#header {
background: url(http://placehold.it/420x160) center top no-repeat;
}
#header-inner {
background: url(http://placekitten.com/150/200) right top no-repeat;
}
.logo-class {
height: 128px;
}
.content {
margin-left: auto;
margin-right: auto;
table-layout: fixed;
border-collapse: collapse;
z-index: -1;
position:relative;
}
.td-main {
text-align: center;
padding: 80px 10px 80px 10px;
border: 1px solid #A02422;
background: #ABABAB;
}
<body>
<div id="header">
<div id="header-inner">
<table class="content">
<col width="400px" />
<tr>
<td>
<table class="content">
<col width="400px" />
<tr>
<td>
<div class="logo-class"></div>
</td>
</tr>
<tr>
<td id="menu"></td>
</tr>
</table>
<table class="content">
<col width="120px" />
<col width="160px" />
<col width="120px" />
<tr>
<td class="td-main">text</td>
<td class="td-main">text</td>
<td class="td-main">text</td>
</tr>
</table>
</td>
</tr>
</table>
</div>
<!-- header-inner -->
</div>
<!-- header -->
</body>
Note: z-index only works on positioned elements (position:absolute, position:relative, or position:fixed). Use one of those.
In my case i had to move the html code of the element i wanted at the front at the end of the html file, because if one element has z-index and the other doesn't have z index it doesn't work.
Another Note: z-index must be considered when looking at children objects relative to other objects.
For example
<div class="container">
<div class="branch_1">
<div class="branch_1__child"></div>
</div>
<div class="branch_2">
<div class="branch_2__child"></div>
</div>
</div>
If you gave branch_1__child a z-index of 99 and you gave branch_2__child a z-index of 1, but you also gave your branch_2 a z-index of 10 and your branch_1 a z-index of 1, your branch_1__child still will not show up in front of your branch_2__child
Anyways, what I'm trying to say is; if a parent of an element you'd like to be placed in front has a lower z-index than its relative, that element will not be placed higher.
The z-index is relative to its containers. A z-index placed on a container farther up in the hierarchy basically starts a new "layer"
Incep[inception]tion
Here's a fiddle to play around:
https://jsfiddle.net/orkLx6o8/