How to place 3 different paragraphs next to each other? - html

In my footer I want to make 3 different sections of paragraphs-at left, middle and right. The 3 paragraphs should sit next to each other, not below each other.
This is how I was trying to do, but I failed to figure it out.
<footer>
<div id="footer_box">
<p id="footer_text_left">
should sit at the left.
</p>
<p id="footer_text_middle">
should sit in the middle.
</p>
<p id="footer_text_right">
should sit at the right.
</p>
</div>
</footer>
.CSS:
#footer_box{
border-top:2px solid #009933;
padding-bottom:75px;
background-color:#3366CC;
}
#footer_text_left{
font-size:15px;
color:black;
font-family:Euphemia;
}
#footer_text_middle{
font-size:15px;
color:black;
font-family:Euphemia;
}
#footer_text_right{
font-size:15px;
font-family:Euphemia;
color:black;
}

First option:
p {
float: left;
}
Second option:
p {
float: left;
width: 30%;
margin: 0 1%;
}
Third option (best):
p {
display: inline-block;
}
Another thing I saw was that every paragraph had the same rules, you could set the font properties on the body or global paragraph so you won't need to set it on everything.
That would look like this:
body {
font-size:15px;
font-family:Euphemia;
color:black;
}
Or if you want it just on the footer paragraphs:
footer p {
font-size:15px;
font-family:Euphemia;
color:black;
}

This is Extremely easy to do, either by making the <p>'s inline-block, or float:left them:
#footer_box p{
display:inline-block;
}
inline-block, (or inline) is the best way to do it, as float:left, has some unwanted effects, such as the <p>'s no longer effect the height of their parent, as can be seen in this JSFiddle, compare it with the one below.
JSFiddle
See this SO question about it: float:left; vs display:inline; vs display:inline-block; vs display:table-cell;

Just capture the paragraph into a div and add style. For example
<div style="float: left; margin-right: 20px">
Here's how I did for a paragraph containing picture: https://jsfiddle.net/xomkq7dv/7/

Related

Getting rid of an offset that doesn't want to leave

I have some nested divs, some of which are supposed to display as a table because it makes my life easier, but one of the innermost divs is being given a 16px offset from the top and I can't get rid of it.
The HTML:
<div class="waiting">
<div class="table-row">
<div class="time">
09:55
</div>
<div class="customer">
<div class="cust-name">
Ana Ling
</div>
<div class="cust-deets">
Female, 51
</div>
</div>
<div class="menu">
TODO
</div>
</div>
</div>
The CSS:
.waiting {
display:table;
width:100%;
padding:0;
margin:0;
height:60px;
color:black;
background:rgb(134, 145, 149);
border-collapse:collapse;
font-family:"Segoe UI",Arial,sans-serif;
}
.waiting .table-row {
display:table-row;
}
.waiting .time {
display:table-cell;
background:rgb(125, 134, 139);
width:60px;
padding:20px 15px;
font-size:14px;
color:rgb(65, 73, 75);
}
.waiting .customer {
display:table-cell;
padding:0;
color:rgb(27, 35, 38);
padding:10px 15px;
}
.waiting .customer .cust-name {
font-size:18px;
margin-top:-16px; /* Undoing IE offset */
vertical-align:top; /* Come on stupid IE */
}
.waiting .customer .cust-deets {
font-size:14px;
margin:0;
}
.waiting .menu {
display:table-cell;
}
To be specific, it is the cust-name div that is being offset by an unnecessary 16px from the top, and neither negative margins nor manually reassigning the top position does anything. I even tried changing the value in the console within the box model, but that 16px just keeps re-asserting itself regardless of what value I change it to. I've also tried setting the position to relative before assigning the top value, but that just made the height of the element bigger.
I am trying to do this in IE11 and this website will only every be viewed on IE11, so if you even just have a hacky solution that only works for IE11, please give it to me!
I think you're going about this the wrong way. You want to show tabular data but you want to avoid using an actual table, presumably because "tables are bad". Tables are considered bad form for layout, it's true, but you're showing structured data. Start by making it a table and style it from there, save yourself a lot of headaches.
Add a vertical align to your .waiting .customer and remove the padding top as well (and remember to remove the negative margin from .cust-name).
.waiting .customer {
display:table-cell;
color:rgb(27, 35, 38);
padding: 0 15px 10px;
vertical-align: top;
}

Html :Adjusting alignment of heading and <p>

i have very simple scenario but i am really stuck with it and need your help please .
this is what i have to do .
This is a div with righ and bottom border and and image in its top . I have to display text same as this one . For this i am using bootstrap like this
<div class="span4" >
<h1 class="BoldText">
GET A QUOTE
</h1>
<span class="SimpleText">
INSERT TEXT HEREINSERT TEXT HEREIN-SERT TEXT HEREINSERT TEXT HEREINSER
</span>
</div>
now problem is that i have to show it in middle of box , if i set margin-left to h1 and <span> tag this is how it looks like this padding also does not work here . will someone guide me how do i adjust it . it seems simple but i am really unable to get it .
I would set widths:
http://jsfiddle.net/4YUtW/
.span4 {
width:300px;
border:1px solid #666;
}
h1 {
width:226px;
display:block;
margin:0 auto;
}
.SimpleText {
width:226px;
display:block;
text-align:justify;
margin:0 auto;
}
but, there are probably better solutions... Of course, you will have to change values to fit your needs.
You will need to set up your CSS as such:
#img {
background:transparent url('http://thebuzzdoha.com/wp-content/uploads/2014/06/fifa-world-cup-wallpaper-hd.jpg') top center no-repeat;
height:200px;
width:100%;
margin:0 0 20px 0;
}
.span4 {
border:1px dotted Black;
margin:0 auto;
width:400px;
text-align:center;
}
.span4 a {
color:Black;
text-decoration: none;
font-family: sans-serif;
}
.SimpleText {
display:inline-block;
margin:0 auto;
width:70%;
text-align:justify;
}
You can see this here->http://jsfiddle.net/5KjXq/
Hope this helps!!!
So, if you're not particularly attached to using bootstrap, doing this in pure html and css is relatively simple and usually a whole lot easier to read than the bootstrap spit-out code. I have made a fiddle with an example: http://jsfiddle.net/6aJJ5/1/. Hope that helps!

Centering 2 divs that may not be always present at the same time CSS

I'm writing a CSS for a store. I need a div that sets the buy button to the left, and a Prev and View Next images to the right, which is working.
My real problem is that sometimes the "buy" button will be not present, because of the PHP.
When the buy button is not present images must be centered, because if they are not, it will be empty space to the left side (where the buy button was)
At first i think on margin:0px auto, but this will need a constant width set, right?
I really thought at the beginning this will be very simple. But i got stuck/
fiddle
Simplified to get the idea
I think im just missing something basic that i cant see know.
HTML:
<div id="comprarbtn">
<div id="wrappcomprarbtn">
<input class="comprarbtn commonButton" type="button" value="Buy Now" id="buynowlogin">
<div id="naviminicc"> <img src="images/navmini_01.png" class="navmini1">
<img src="images/navmini_02.png" class="navmini2" rel="#mies1"> <img src="images/navmini_03.png" class="navmini3">
</div>
</div>
</div>
CSS:
.comprarbtn { width:175px;
line-height:51px;
background-image:url(image.jpg);
border:0px;
font-size:12px;
padding-left:10px;
cursor:pointer;
overflow:hidden;
text-indent:0px;
z-index:10;
}
#comprarbtn {
float:left;
position:absolute;
width:321px;
text-align:center;
height:51px;
z-index:1000;
display:table-cell;
background-color:#f4f4f4;
}
#wrappcomprarbtn { margin:0px auto;}
#naviminicc { width:145px; float:right;}
#naviminicc a { margin:0px; padding:0px; }
.navmini1 { cursor:pointer; margin:0px; }
.navmini2 {cursor:pointer; margin:0px; }
.navmini3 {cursor:pointer; margin:0px; }
#navmini { width:135px; max-width:135px;}
I'm not sure what's going on with the CSS and HTML you posted, but to achieve what you want to do in theory:
Give the wrapping div a fixed width large enough to contain both the button and the images
Give it margin: 0 auto to center it and text-align: center.
Make the inner contents display: inline
css:
.wrapper {
width: 200px; /* Large enough to contain everything */
text-align: center;
margin: 0 auto;
}
.wrapper .buttons {
display: inline;
}

CSS floats funky

My floats are acting strange (well I guess they're acting how they're supposed to), but I can't seem to understand why. For some reason the div box that contains 'Alex' always goes down to another line. Is there something I'm messing up?
style.css
.clear {
clear:both;
}
.page-header {
width:100%;
background:#efefef;
border-bottom:1px #ddd solid;
padding:3px 10px;
margin-bottom:24px;
}
.page-header-title {
width:200px;
float:none;
}
.page-header-search {
float:left;
width:100px;
}
.page-header-top_menu {
float:right;
width:200px;
}
index.html
<div class="page-header">
<div class="page-header-search">
blah
</div>
<div class="page-header-title">
Calender
</div>
<div class="page-header-top_menu">
Alex
</div>
<div class="clear"></div>
</div>
Thank you very much.
If you exchange the
float: none;
for the "calender"-div with
float: left;
the "Alex" behaves better.
You didn't specify how it should look like.
http://jsfiddle.net/wDp3p/ << I visualized your div-structure with red borders.
http://jsfiddle.net/wDp3p/1/ << version with float: left;
"float" is not really for solutions like table columns but for floating - so the "calender"-div floats directly after its left hand previous element.
You're floating it wrongly. You should assign a float property to .page-header-title.

How can I center my text using Divs

I had this code and it worked good. The footer information was at the bottom of my screen in the middle:
div#footercenter p { font-size: 0.9em; }
<div id="footercenter">
<p>© XXXX </p>
</div>
I wanted to change it to this:
div#footercenter {}
div#footer-message { font-size: 0.9em; color: #EEEEEE; display: inline;}
div#footer-copyright { font-size: 0.9em; color: #EEEEEE; display: inline; }
<div id="footercenter">
<div id="footer-copyright">xxx</div>|
<div id="footer-message">yyy</div>
</div>
Now my text is to the left and not in the center. Does anyone have any idea how I can make it go back to the center?
Dave
You mean like this? : http://jsfiddle.net/jomanlk/DHA9A/
You just need to add text-align to center
div#footercenter {text-align: center}
Should be as simple as this:
#footercenter {
text-align:center;
}
But you may need to do this as well if you have other styles interfering:
#footercenter div {
float:none;
display:inline; /* or inline-block */
}
A <div> is a block element that should be used for defining collections of elements rather than explicitly for text content. There's nothing wrong with your markup but you have set your divs to then have a display:inline which means they only occupy the width of their content. The divs will also bunch up to the left by default.
The better approach would have been to contain the text within 2 span elements and then simply set the text-align property of the parent div to center.
See the following;
div#footercenter { font-size: 0.9em; color: #EEEEEE; text-align:center; }
<div id="footercenter">
<span>xxx</span>|
<span>yyy</span>
</div>
Try
div#footercenter {
text-align:center;
}
<div id="footercenter">
<span id="footer-copyright">xxx</span>|
<span id="footer-message">yyy</span>
</div>
Rewrite your footercenter class as
div#footercenter {text-align:center;}
Set the width for the div you wanna apply the text-align property to and then assign text-align : center.