divs not floating to the center - html

im trying to create this:
but the images are floating to the right and not stick at the center.
and the text floating to the left and not in the center.
and the "OR" is not in the middle.
here is my code:
<div class='container' >
<span style="float:left; margin-left:20px;">
<div class='textrtl' style="text-align: center;"><h5>WhatssApp</h5></div>
<div class='pickbuttonplatform' id='image0a' ><img alt="" src="http://placehold.it/90x70" style="width:100px; height:100px;"></div>
<div class='textrtl' style="text-align: center;">Recommended to Europe, India, Brazil and Israel</div>
</span >
OR
<span style="float:right; margin-left:20px;">
<div class='textrtl' style="text-align: center;"><h5>SMS</h5></div>
<div class='pickbuttonplatform' id='image0a' ><img alt="" src="http://placehold.it/90x70" style="width:100px ; height:100px;"></div>
<div class='textrtl' style="text-align: center;">Recommended to the United States</div>
</span>
</div>
what should i do??

Add the following CSS:
.pickbuttonplatform{
text-align:center;
}
Here is the JSFiddle demo

to align or in middle use inline-block see snippet below
img{display: block; margin: 0 auto;}
.txt-block{display: inline-block; vertical-align: middle; text-align: center;}
.img-block{display: inline-block; vertical-align: middle; width: 40%;}
<div class='container' >
<span class="img-block">
<div class='textrtl' style="text-align: center;"><h5>WhatssApp</h5></div>
<div class='pickbuttonplatform' id='image0a' ><img alt="" src="http://placehold.it/90x70" style="width:100px; height:100px;"></div>
<div class='textrtl' style="text-align: center;">Recommended to Europe, India, Brazil and Israel</div>
</span >
<span class="txt-block">
OR
</span >
<span class="img-block">
<div class='textrtl' style="text-align: center;"><h5>SMS</h5></div>
<div class='pickbuttonplatform' id='image0a' ><img alt="" src="http://placehold.it/90x70" style="width:100px ; height:100px;"></div>
<div class='textrtl' style="text-align: center;">Recommended to the United States</div>
</span>
</div>

By default everything is left aligned so you need to define it if you want to centre align the elements.
Here you can use text-align:center
<div class='container'>
<span style="float:left; margin-left:20px;">
<div class='textrtl' style="text-align: center;"><h5>WhatssApp</h5></div>
<div class='pickbuttonplatform' id='image0a' style="text-align:center;"><img alt="" src="http://placehold.it/90x70" style="width:100px; height:100px;"></div>
<div class='textrtl' style="text-align: center;">Recommended to Europe, India, Brazil and Israel</div>
</span >
<span style="float:right; margin-left:20px;">
<div class='textrtl' style="text-align: center;"><h5>SMS</h5></div>
<div class='pickbuttonplatform' id='image0a' style="text-align:center;"><img alt="" src="http://placehold.it/90x70" style="width:100px ; height:100px;"></div>
<div class='textrtl' style="text-align: center;">Recommended to the United States</div>
</span>
</div>
OR
use this css if you can
.pickbuttonplatform{
text-align:center;
}
Example : https://jsfiddle.net/g5emes1v/
In your structure you are using #image0a id twice which is not valid. You cannot use same id multiple times in one page

Related

How to align a div in center respective to the div below it?

How can I align img in center to the respective to the text below it? The wrapper div is aligned left.
<div class="wrapper">
<div class="com-icon">
<img src="images/IT.png" alt="laptop logo">
</div>
<div class="com-text">
<p>IT Solutions</p>
</div>
</div>
Add another wrapper around the com-icon and com-text. And then align that were you want it. Example below:
<div class="wrapper">
<div class="wrapper-inner">
<div class="com-icon">
<img src="images/IT.png" alt="laptop logo">
</div>
<div class="com-text">
<p>IT Solutions</p>
</div>
</div>
</div>
Add this to your css file:
.wrapper{
text-align: center;
}
or if you just want to check if it's working you can add the infamous inline style.
This not a recommended method other than just to see if it's OK!
<div class="wrapper" style="text-align:center;">
<div class="com-icon">
<img src="images/IT.png" alt="laptop logo">
</div>
<div class="com-text">
<p>IT Solutions</p>
</div>
</div>
make a table
table.center {
text-align: center;
margin-left: auto;
margin-right: auto;
}
.com-text,
.com-icon {
margin: auto;
}
<div class="wrraper">
<table class="center">
<tr>
<td>
<div class="com-icon">
<img src="image.jpg" alt="laptop logo">
</div>
</td>
</tr>
<tr>
<td>
<div class="com-text">
<p>IT Solutions</p>
</div>
</td>
</tr>
</table>
</div>

Display <img> and <p> in-line

I would like my image to come right after my <p> tag in the same line. I tried to wrap them inside a <div> block with display:inline-block set but to no avail.
<div style="float:left; display:inline-block; ">
<span style="float:left;width: 50%;">
<p style="float:left; display:block;" class="sentiment">Sentiment</p>
</span>
<span style="float:right;width: 50%;">
<img src="https://storage.googleapis.com/gweb-uniblog-publish-prod/static/blog/images/google.a51985becaa6.png" style="width:20px;height:20px;">
</span>
</div>
http://jsfiddle.net/BMv5u/59/
Try adding inline-block to each of the sub elements:
<div>
<p style="display:inline-block;" class="sentiment">Sentiment</p>
<img style="width:20px;height:20px;display:inline-block" src="https://storage.googleapis.com/gweb-uniblog-publish-prod/static/blog/images/google.a51985becaa6.png">
</div>
You can use align property on the img. check the fiddle here
<p >
<img src="https://storage.googleapis.com/gweb-uniblog-publish-prod/static/blog/images/google.a51985becaa6.png" ALIGN="right" alt="">
Sentiment
</p>

Turn Html table row into two floating divs with css

I am trying to transfer a table into a set of floating divs and I can't seem to get it. How can I make .div1 and .div2 behave like .td1 and .td2?
UPDATED (also replaced prior icon with image to show more clearly the issue.
Fiddle showing how it SHOULD work
table (before)
<table>
<img src="http://placehold.it/60x60">
</td>
<td class="td2" style="padding-left: 8px">
<h4>
<strong>
Title
</strong>
</h4>
<span>
Here is come placeholder Text
</span>
</td>
Fiddle showing how it doesn't work with divs
divs (after? Not working)
<div class="div_wrapper" style="display:inline-block">
<div class="div1" style="width: 62px; vertical-align: top; padding-top:5px">
<img src="http://placehold.it/60x60">
</div>
<div class="div2" style="padding-left: 8px">
<h4>
<strong>
Title
</strong>
</h4>
<span>
Here is come placeholder Text
</span>
</div>
In that case you can use float.
http://jsfiddle.net/n69aro2x/1/
Here is the code :-
<div class="div_wrapper" style="display:inline-block">
<div class="div1" style="width: 62px; vertical-align: top; padding-top:5px; float:left">
<img src="http://placehold.it/60x60">
</div>
<div class="div2" style="padding-left: 8px; float:left;">
<h4>
<strong>
Title
</strong>
</h4>
<span>
Here is come placeholder Text
</span>
</div>
</div>
</div>
You can use margin to align text :-
<div class="form-group" style="display:inline-block">
<div class="div1" style="width: 33px; vertical-align: top; padding-top:5px">
<i class="fa fa-cog" style="font-size: 36px"></i>
</div>
<div class="div2" style="padding-left: 8px">
<h4>
<strong style="margin-left:30px;">
Title
</strong>
</h4>
<br/>
<span style="margin-left:30px;">
Here is come placeholder Text
</span>
</div>
</div>
</div>
hi the below is given the using table and using div's both demo code
here is the demo code using table
Dmo code using table
<table>
<tr>
<td class="td1" width= "33" style="vertical-align: top; padding-top:5px">
<i class="fa fa-cog " style="font-size: 36px"></i>
</td>
<td class="td2" style="padding-left: 8px">
<h4>
<strong>
Title
</strong>
</h4>
<br/>
<span>
Here is come placeholder Text
</span>
</td>
</tr>
</table>
here is the demo code made using div's
Demo code made using div's
<div class="form-group" style="display:inline-block">
<div class="div1" style="width: 33px; vertical-align: top; padding-top:13px">
<i class="fa fa-cog" style="font-size: 36px"></i>
</div>
<div class="table_wrapper_div">
<div class="div2" style="padding-left: 53px;">
<h4><strong>Title</strong></h4><br/>
<span>Here is come placeholder Text</span>
</div>
</div>

How to align text in line with icons?

http://jsfiddle.net/acz3hhsL/
Code:HTML
<div id="contact-info">
<div id="adresa">
<div id="addPadding" style="padding: 2em;">
<img src="http://avocat.dac-proiect.ro/wp/wp-content/themes/twentyfourteen/images/ADRESA.png" style="width:22px;height:31px;float:left;display: inline;">
<div style="float: right;display: inline;width: 80%;">
<p style="text-align:left;font-size:14px;color:black;">Calea Dorobantilor,nr.74,<br>bl.Y9,SC.2,Ap.25<br>Cluj-Napoca,400609<br>Romania</p>
</div>
</div>
</div>
<div id="telefon">
<div id="addPadding" style="padding: 60px 2em;">
<img src="http://avocat.dac-proiect.ro/wp/wp-content/themes/twentyfourteen/images/TELEFON.png" style="width:22px;height:31px;float:left;display: inline;">
<div style="float: right;display: inline;width: 80%;">
<p style="font-size:14px;color:black;text-align:left;">Tel./Fax (004) 0264 448 579<br>Tel.(004) 0744 490 776</p>
</div>
</div>
</div>
<div id="mail">
<div id="addPadding" style="padding: 20px 2em;">
<img src="http://avocat.dac-proiect.ro/wp/wp-content/themes/twentyfourteen/images/E-MAIL.png" style="width:26px;height:19px;float:left;display: inline;">
<div style="float: right;display: inline;width: 80%;">
<p style="font-size:14px;color:black;text-align:left;">office#codoban.com</p>
</div>
</div>
</div>
</div>
</div>
Code CSS:
#contact-info
{
width:268px;
height:270px;
background:url(http://avocat.dac-proiect.ro/wp/wp-content/themes/twentyfourteen/images/BODY-CONTACT.png);
position:absolute;
right:0;
}
This is the site:
http://avocat.dac-proiect.ro/wp
I changed the text font size and unfortunately not displayed inline with icon sites.
How can I get him back but font-size:14px;
Can you help me please to solve this problem?
Thanks in advance!
Add
p {margin: 0;}
to your CSS, that removes the gaps/offset of the text. http://jsfiddle.net/acz3hhsL/2/

Float left not working in mobile devices like ipod, android smartphones

Floating left 'li' not working in ipod, android devices. But it works perfect in all major broswers in laptop / destops. Code is here:
<ul class="clsvideos clearfix">
<li>
<div class="home-thumb">
<div class="home-play-container">
<div class="play-button-hover">
<div class="movie-entry yt-uix-hovercard">
<div class="tooltip">
<img class="yt-uix-hovercard-target" src="http://img.youtube.com/vi/pF6Yq7DrJKA/1.jpg" border="0" width="140" height="83" title="">
<div class="Tooltipwindow clearfix">
<img src="http://video.muslimbackyard.com/templates/videoplus/images/tip.png" class="tipimage">
<div class="clearfix"><span class="clstoolleft">Category : </span><span class="clstoolright">Education & Travel</span></div>
<span class="clsdescription">Description : </span><p>Abdul Basit reciting Surah Infitar - amazing tajweed! mash'Allah!</p><div class="clearfix"> <span class="clstoolleft">Rating : </span> <div class="clstoolright ratingvalue ratethis1 fivepos1"></div>
<div class="clearfix"><span class="clstoolleft"> Views:</span> <span class="clstoolright">58 </span></div>
</div>
</div>
</div>
</div>
</div>
<div class="show-title-container">
Abdul Basit reciting Surah Infitar
</div>
<span class="video-info"> Education & Travel </span>
<div class="video-info clearfix">
<div class="clsratingvalue"><span class="ratethis1 fivepos1 "></span></div>
<div class="clsvideosviews">58 Views</div>
</div>
</div>
</div></li>
<li>
<div class="home-thumb">
<div class="home-play-container">
<div class="play-button-hover">
<div class="movie-entry yt-uix-hovercard">
<div class="tooltip">
<img class="yt-uix-hovercard-target" src="http://img.youtube.com/vi/IYMKQKSV0bY/1.jpg" border="0" width="140" height="83" title="">
<div class="Tooltipwindow clearfix">
<img src="http://video.muslimbackyard.com/templates/videoplus/images/tip.png" class="tipimage">
<div class="clearfix"><span class="clstoolleft">Category : </span><span class="clstoolright">Sports & Gaming</span></div>
<span class="clsdescription">Description : </span><p>How the Bible Led Me to Islam: The Story of a Former Christian Youth Minister - Joshua Evans</p><div class="clearfix"> <span class="clstoolleft">Rating : </span> <div class="clstoolright ratingvalue ratethis1 fourpos1"></div>
<div class="clearfix"><span class="clstoolleft"> Views:</span> <span class="clstoolright">41 </span></div>
</div>
</div>
</div>
</div>
</div>
<div class="show-title-container">
How the Bible Led Me to Islam: The ...
</div>
<span class="video-info"> Sports & Gaming </span>
<div class="video-info clearfix">
<div class="clsratingvalue"><span class="ratethis1 fourpos1 "></span></div>
<div class="clsvideosviews">41 Views</div>
</div>
</div>
</div></li>
Corresponding CSS is:
.clsvideos li:first-child {
width: 140px;
float: left;
padding: 14px 10px 0 0;
display: block;
}
.clsvideos li {
height: 155px;
width: 140px;
padding: 14px 10px 0 9px;
border-right: 1px dotted #CFCFCF;
border-bottom: 1px dotted #CFCFCF;
float: left;
}
Live URL: http://video.muslimbackyard.com/
Note: Open the site in a smartphone and destop. Note the disign issues at Popular Videos, Recent Videos section. You will know where the problem exists.
Awaiting for a solution at the earliest
Actually the problem was, the developer hadn't closed the last 'div' inside 'li' which led to this bug...
"So be careful with front-end code while writing core php". This is what the advise I have to my developer.