I am trying to create a footer bar which has a text element aligned on the left and one thats aligned to the right, however I'm having some difficulty.
This is what I have so far:
HTML
<div id="footer_bar">
<div id="footer_bar_content">
<p>
Left Text
</p>
<p class="align_right">
Right Text
</p>
</div>
</div>
CSS
#footer_bar
{
width:100%;
position:absolute;
margin:0;
bottom:0;
height:30px;
border-top:2px #eeeeee solid;
background-color:#f7f7f7;
}
#footer_bar_content { padding-left:15%; padding-right:15%; }
#footer_bar_content p { line-height:30px; margin:0; color:#222; font-size:11px; display:inline; }
.align_right { text-align:right; width:100%; }
Please could someone help me work out what is wrong? The align_right class doesn't appear to have any effect.
Is this what you are looking for. Take a look at fiddle. http://jsfiddle.net/GD8tL/1/
Use float instead of align
#footer_bar
{
width:100%;
position:absolute;
margin:0;
bottom:0;
height:30px;
border-top:2px #eeeeee solid;
background-color:#f7f7f7;
}
#footer_bar_content { padding-left:15%; padding-right:15%; }
#footer_bar_content p { line-height:30px; margin:0; color:#222; font-size:11px; display:inline; }
.align_right{ float:right;}
#footer_bar_content p.align_right {float:right; width:100%;}
Try this if you want your text on the right side, and play a bit with the width, because you want to give 100% of the main div's width, which is the whole place, so probably it will be displayed in new line.
<div id="footer_bar">
<div id="footer_bar_content">
<p>
Left Text
<span style="float: right;">
Right Text
</span>
</p>
</div>
</div>
You must remove width = 100% in class align_right and use "float: right" instead of "text-align:right"
CSS:
.align_right { float:right;}
Code: JSFIDDLE
instead of paragraph you should take left.. similar for right and use .left{float:left} and .right{float:right} then .footer_bar_content:after{clear:both} will work for u
You can try float right or left accordingly,
Html
<div id="footer_bar">
<div id="footer_bar_content">
<p class="left">
Left Text
</p>
<p class="right">
Right Text
</p>
</div>
</div>
StyleSheet
#footer_bar
{
width:100%;
position:absolute;
margin:0;
bottom:0;
height:30px;
border-top:2px #eeeeee solid;
background-color:#f7f7f7;
}
#footer_bar_content { padding: 0 15%; }
#footer_bar_content p { line-height:30px; margin:0; color:#222; font-size:11px; display:inline; }
.right { float:right; }
.left { float:left; }
Here is the Demo
Related
I am trying to put a title in a div toolbar next to some pictures. The problem is that my text is not well placed, it should be at least on top of the toolbar but instead it is at bottom and doesn't move.
I would like it to be in the vertical middle at left near the pictures.
Here is a codepen : http://codepen.io/anon/pen/fDojK
And a picture :
Here is the html part of the title bar:
<div id="bar" >
<div id="picturesmenu">
<img src='images/back.jpg' alt='back' />
<img src='images/home.jpg' alt='home' />
<img src='images/reload.jpg' alt='reload' />
</div>
<div id="titlemenu">Main</div>
</div>
<div id="body">
...
And style :
#bar
{
width:100%;
height:50px;
padding-top:3px;
padding-left:10px;
border-bottom:2px solid white;
vertical-align:top;
}
#picturesmenu
{
margin:0;
padding:0;
display:inline;
}
#bar img
{
border:3px solid white;
width:40px;
margin:2px;
}
#titlemenu
{
margin:0;
padding-left:20px;
height:100%;
display:inline;
font-size:20pt;
font-weight:bold;
color:white;
}
#bar span
{
margin-left:20px;
margin-top:200px;
font-size:20pt;
font-weight:bold;
color:white;
}
I tried vertical align and margin but the "Main" text doesn't move...
Thanks in advance before I change anything into tables ;)
[EDIT]
Thank you all for your answers ! I didn't thought about handling the alignment of the content (#titlemenu) instead of the container (#bar), it's not very logical...
You need to work the vertical align for both #picturesmenu and #titlemenu and remove the padding left for that title if you want it to the left. Then work with inline-block elements. Like this:
EDITED WITH CROSS-BROWSER CODE
html, body {
height:100%;
width:auto;
padding:0;
margin:0;
background-color:black;
}
#bar {
width:100%;
height:auto;
padding-top:3px;
padding-left:10px;
border-bottom:2px solid white;
display:block;
}
#picturesmenu {
margin:0;
padding:0;
}
#bar img {
border:3px solid white;
width:40px;
margin:2px;
display:inline-block;
vertical-align:middle;
width:40px;
height:50px;
}
#titlemenu {
margin:0;
padding-left:0px;
display:inline-block;
vertical-align:middle;
font-size:20pt;
font-weight:bold;
color:white;
}
.item {
float:left;
width:120px;
height:120px;
border:2px solid white;
text-align:center;
margin:20px;
padding:20px;
}
.picitem {
height:70%;
margin-bottom:25px;
border:2px solid white;
}
.textitem {
underline:none;
color:black;
font-size:16pt;
color:white;
}
I have forked your CodePen
However, a way better approach would be to give #bar a display:block property and then add inline-block to everything inside, but if you want it to work as in your description, there you go
Add these lines to the #titlemenu in CSS
padding:10px;
display:inline-block;
vertical-align:top;
By vertical-align:top, the block gets aligned to the top of the parentdiv and you set padding to fit the height of the block to the height of the parent div
Demo
In my last question I asked how could I add text onto the gray area of the picture, some guys suggested using <span>, I ended up with all the text (because it is a span after all, inline) on top of each other in a single line (left picture), even though it was set to display:block. How can I break it into seperate lines as seen in the picture on the right?
and does it make sense using h4/h5 for the styling or I should use different div's or something?
HTML:
<div class="rightCol1">
<img src="pic1.png"><span><h4>2014 02 16</h4><h5>po pirmojo etapo <br> naudingiausi - osvaldas <br> sarpalius ir lukas šukutis</h5></span>
<img src="pic2.png"><span><h4>2014 02 16</h4><h5>geriausias sezono <br> startas per visą klubo <br> istoriją </h5></span>
</div>
CSS:
.rightCol1{
float:right;
margin-right:150px;
margin-top:10px;
}
.rightCol1 a {
background:green;
display: block;
position:relative;
height:200px;
width:100px;
margin-bottom: 160px
}
.rightCol1 a span {
line-height:0px;
display:block;
margin-left:15px;
width:234px;
height:70px;
position:absolute;
bottom:-80;
left:0;
z-index:1;
}
h4{
padding:0;
margin:0;
font-style:;
color:#e6540c;
font-weight:bold;
font-size:14;
}
h5{
padding:0;
text-transform:uppercase;
color:rgb(193,193,193);
}
It's because your span has no line height, so each on the lines will come out ontop of each other. I suggest removing line-height from your span CSS:
.rightCol1 a span {
display:block;
margin-left:15px;
width:234px;
height:70px;
position:absolute;
bottom:-80px;
left:0;
z-index:1;
}
Im trying to align my title, image and paragraph to the left of my news image.
And Im using float left for doing this but its not working,
Im having this:
But Im trying this:
Do you see where might be the problem?
My fiddle with the problem Im having:
http://jsfiddle.net/upH4U/1/
My html:
<div id="news-content">
<h1>News</h1>
<article id="loop-news">
<div class="img_container">
<img src="../image1.jpg" title=""/>
</div>
<h2><a href="#" >Title of the news</a><br /></h2>
<span id="date">Tuesday, May, 2014</span>
<p>
This is my paragraph and I want to align it to left of my image.
see more
</p>
</article>
<article id="loop-news">
<div class="img_container">
<img src="../image1.jpg" title=""/>
</div>
<h2><a href="#" >Title of the news</a><br /></h2>
<span id="date">Tuesday, May, 2014</span>
<p>
This is my paragraph and I want to align it to left of my image.
see more
</p>
</article>
</div>
My css:
#news-content
{
float:left;
width:480px;
background:#f3f3f3;
}
#news-content h1
{
font-size:20px;
font-weight:100;
margin-bottom:10px;
color:gray;
text-align:left;
}
#loop-news
{
width:400px;
margin-bottom:10px;
text-align:center;
}
.img_container
{
width:160px;
height: 165px;
float:left;
cursor: pointer;
border:3px solid #ccc;
}
#loop-news h2 a
{
font-size:20px;
color:#3B5998;
text-decoration:none;
margin:0 auto 0 5px;
font-weight:100;
float:left;
}
#loop-news a
{
font-size:14px;
text-decoration:none;
margin-left:2px;
}
#loop-news #date
{
font-size:13px;
font-weight:normal;
color:#7a7a7a;
}
#loop-news p
{
font-size: 13px;
text-align:justify;
line-height:25px;
word-spacing:-2px;
width:300px;
float:left;
margin-left:5px;
}
quick answer, use clearfix - there are a few options there
CSS
#loop-news
{
width:400px;
/*margin-bottom:10px; moving margin to seperator*/
/*text-align:center;*/
}
#loop-news p
{
font-size: 13px;
/*text-align:justify;
line-height:25px;
word-spacing:-2px;
width:300px;
float:left;*/
margin-left:5px;
}
#loop-news {
overflow:hidden; /*quick clear fix*/
}
.loop-news-content {
overflow:hidden;
}
#loop-news *:first-child { margin-top:0; }
#loop-news *:last-child { margin-bottom:0; }
#loop-news h2 { margin:0; }
.loop-news-meta { margin-top:0; }
Heres the updated fiddle
http://jsfiddle.net/Varinder/HTNk8/2/
Here's a page to show how to align text relative to an image:http://www.w3schools.com/tags/att_img_align.asp
your width is overflow; dont use it or fix it
#loop-news p
{
font-size: 13px;
text-align:justify;
line-height:25px;
word-spacing:-2px;
float:left;
margin-left:5px;
}
float the image to the right like this fiddle
float:right;
You need to clear your float by adding clear:left; to the same class that uses float: left. In your case, you can use the CSS declaration:
#news-content article { clear: left; }
Also, having multiple elements with the same ID can have unexpected results. You should consider using classes instead.
I'm trying to create something that looks like this:
so far I have: http://jsfiddle.net/ePse6/
Without using something like: margin-top:-25px;, how can I position the Edit/Delete links to be on the right of the title (the part that says "iPhone" or "Android") and have both the title and links halfway between the borders?
Thanks!
just like most of answers, here i come with text-align:right and float:left .
I reduced code to minimal and plain CSS for your actual structure and to make it clear to you : http://jsfiddle.net/ePse6/7/
ul , a { /* basic reset we need */
padding:0;
margin:0;
color:gray;
text-decoration:none;
}
.mini > ul > li {
display:block;/* reset from list-item */
border-bottom:solid;
text-align:right;
overflow:hidden;/* wraps floatting element within */
}
.mini > ul > li> h3 {
float:left;
margin:0;
}
.mini > ul > li ul,
.mini > ul > li li {
display:inline-block;
}
Why not use something simple and really handy?
I have removed all of your messy code, and have created a new fiddle for you.
http://jsfiddle.net/afzaal_ahmad_zeeshan/ePse6/4/
I have used just a few lines of code, I have used a div and inside that, I have used 2 paragraphs to seperate each of them. Then inside that I used span element to seperate the right and left floating elements.
Using CSS I selected the classes and then styled them to get the desired input!
Here is the code:
<div>
<p>
<span class="left">Android</span><span class="right">Delete Edit</span>
</p>
<p>
<span class="left">iPhone</span><span class="right">Delete Edit</span>
</p>
</div>
CSS is as:
p {
border: 1px solid #333; // border that you wanted!
padding: 20px; // padding all around the element
padding-bottom: 40px; // padding at the bottom of the element
}
.left {
float: left; // making the elements float at the left
}
.right {
float: right; // floating elements at the right side
}
You can go to the fiddle page, and check for the design of the layout now. It was a simple thing. Hope its what you wanted.
This is without the lists. Just some CSS to do the trick: http://jsfiddle.net/Lg96p/
CSS:
.wrap{
width:100%;
border-bottom:solid 1px #666666;
margin-bottom:20px;
padding-bottom:10px;
}
.title{
font:bold 16px arial;
}
.fl{
float:left;
}
.fr{
float:right;
}
.lnk{
color:#6c6c6c;
display:inline-block;
text-align:right;
margin:0 10px 0 0;
text-decoration:none;
font:normal 14px arial;
}
HTML:
<div class="wrap fl">
<div class="title fl">iPhone</div>
<div class="fr"><a class="lnk" href="">Edit</a><a class="lnk" href="">Delete</a></div>
</div>
<div class="wrap fl">
<div class="title fl">Android</div>
<div class="fr"><a class="lnk" href="">Edit</a><a class="lnk" href="">Delete</a></div>
</div>
You should create two columns that fill the parent div. Make them both float:left; and for the right column you can align the text to the right text-align:right; or put two divs in it with float:right; for edit and delete.
Here is my fiddle: http://jsfiddle.net/ePse6/5/
Whatever you put into the columns or how to format it is up to you. But from here you have 2 columns independently next to each other.
If you want multiples of these stacked on top of each other i would change the container to a class and just add multiple of these containers with the columns to keep it tidy and readable. Like in this fiddle: http://jsfiddle.net/ePse6/6/
HTML:
<div class='container'>
<div class='leftCollumn'>
Iphone
</div>
<div class='rightCollumn'>
<a hreft="">Edit</a><a hreft="">Delete</a>
</div>
</div>
<div class='container'>
<div class='leftCollumn'>
Iphone
</div>
<div class='rightCollumn'>
<div class="button">Edit</div><div class="button">Delete</div>
</div>
</div>
CSS:
.container
{
width:600px;
margin:auto;
}
.leftCollumn
{
float:left;
width:400px;
background-color:#999;
}
.rightCollumn
{
float:left;
width:100px;
text-align:right;
background-color:#CCC;
}
.rightCollumn a
{
margin-left:10px;
margin-right:5px;
}
.button
{
margin-left:10px;
margin-right:5px;
background-color:#000;
color:#FFF;
float:right;
}
Hi i'm trying to make a div within the front page of my site that contains a floating img and some floating text h3, p and a . I then want to loop the div below with different text/pic . When i do this once it works fine but the container div hasn't stretched to fit the content . So when I add another below it overlaps .
code:
<div id="blog">
<h1>BLOG</h1>
<div id="postcont">
<img src="blog1.png" width="40" height="40" />
<h3>Playing At The Phenoix</h3>
<p>So we arrived down at the phenoix about 10 past ten .Rommy was all ready out of it and wasn't sure if he could do...read more </p
>
</div>
<div id="postcont">
<img src="blog1.png" width="40" height="40" />
<h3>Playing At The Phenoix</h3>
<p>So we arrived down at the phenoix about 10 past ten .Rommy was all ready out of it and wasn't sure if he could do...read more </p
>
</div>
</div>
#blog {
float:left;
width:400px;
border-top:#0FF solid 6px;
}
#postcont {
padding:10px;
border-top:1px #FFF solid;
margin-top:10px;
}
#blog h1 {
font-size:20px;
color:#FFF;
padding:10px;
padding-left:0px;
letter-spacing:2px;
}
#blog p {
font-size:15px;
color:#FFF;
float:right;
clear:right;
width:300px;
margin-right:30px;
letter-spacing:2px;
margin-top:5px;
}
#blog a {
font-size:15px;
color:#FFF;
float:right;
clear:right;
width:300px;
margin-right:0px;
letter-spacing:2px;
margin-top:5px;
font-style:italic;
text-decoration:underline;
}
#blog h3 {
font-size:15px;
color:#FFF;
float:right;
clear:right;
width:300px;
margin-right:30px;
letter-spacing:2px;
margin-top:5px;
font-weight:bold;
}
#blog img {
float:left;
clear:left;
}
Block-level elements to not expand to the height of floated elements unless you tell them to. You should add a clearing-element after the last floated element to fix this problem. Instead of:
</div>
</div>
Use:
</div>
<br style="clear: both"/>
</div>
For an extended explanation of this solution, as well as an alternative solution, please see: http://www.quirksmode.org/css/clearing.html