Trouble with aligning items - html

Hello so while creating a site I've been working on I've ran into a problem. I have a link and next to it I have an image. The link is aligning the text in the link with the bottom of the image. I would like the surrounding box around the link to align with the bottom of the image without living a ~20px area below it. The code to see what I mean is below.
HTML:
<div id="links">
Link1
Link2
<img id="logo" src="http://upload.wikimedia.org/wikipedia/commons/0/0a/350x175.jpg" />
Link3
Link4
</div>
CSS:
#links{
/* SIZING */
width:70%;
min-width:625px;
min-height:10px;
/* POSITIONING */
margin-left:auto;
margin-right:auto;
background-color:#FF0;
}
.links {
/* DISPLAY */
display:inline-block;
background-color:#CCC;
border-radius:15px;
box-shadow: 2px 2px 5px #888888;
/* SIZING */
width:calc(16.25% - 10px);
height:50px;
margin:5px;
/* TEXT */
line-height:50px;
text-align:center;
text-decoration:none;
font-size:auto;
color:#000;
}
#logo{
text-decoration:none;
border:0px;
width:calc(35% - 10px);
padding-top:10px;
}

If you set the vertical-align to bottom it will align to the bottom like so;
.links {
background-color: rgb(204, 204, 204);
border-radius: 15px;
box-shadow: 2px 2px 5px rgb(136, 136, 136);
color: rgb(0, 0, 0);
display: inline-block;
height: 50px;
line-height: 50px;
margin: 5px;
text-align: center;
text-decoration: none;
vertical-align: bottom; //// ADDED STYLE
width: calc(16.25% - 10px);
}
Demo Here

Related

Can't move elements in css divs

For some reason I have a parent div called banner which contains a number of child divs, however in my css styles sheet I can't seem to move any elements especially the "CRAFT412" logo image to my desired position within the banner. I've tried using left/right/top/bottom to move these elements but nothing seems to budge them. If anyone could help me here I'd appreciative it.
Here is my HTML for a page on my site
<!--TOP BANNER SECTION-->
<div id="banner">
<div id="logo">
<img src="images/CRAFT412 - Logo.png" width="500" height="281" alt="CRAFT412">
</div>
<div id="ip_box"></div>
<div id="ip_text">
<p>SERVER IP<P/>
<p>craft412.serveminecraft.net<P/>
</div>
<div id="teamspeak_box"></div>
<div id="teamspeak_box_2"></div>
<div id="teamspeak_text">
<p>TEAMSPEAK<P/>
</div>
<div id="teamspeak_image">
<a href="ts3server://craft412.serveminecraft.net:9987">
<img src="images/CRAFT412 - Box - Teamspeak.png" alt="TEAMSPEAK">
</a>
</div>
</div>
Also here is my CSS for the same divs
/*CSS FOR ALL PAGES*/
/*BODY/WRAPPER SECTION*/
body {
background:#EEEEEE;
background-repeat: no-repeat;
background-attachment: fixed;
}
#wrapper {
width: 1750px;
margin: 0 auto;
background-color: white;
border-radius: 5px;
box-shadow: 0px 1.5px 2px 0px;
border: 1.5px solid #E0E0E0;
color: #E0E0E0;
}
/*TOP BANNER SECTION*/
#banner { height:100px; }
#logo {}
#ip_box {
width:200px;
height:43px;
background:#212121;
border-radius: 5px;
box-shadow: 1px 1px 5px;}
#ip_text {
color: white;
font-size: 15px;
}
#teamspeak_box {
width:159px;
height:43px;
background:#212121;
border-radius: 5px;
box-shadow: 1px 1px 5px;
}
#teamspeak_box_2 {
width:43px;
height:43px;
background:#313131;
border-radius: 5px 0px 0px 5px;
}
#teamspeak_text { color: white; }
#teamspeak_image {}
Give the parent div a property :
Position:relative;
Also give the property to child div:
Position:absolute;
Now you can change the places of child div inside the "BANNER" div. by using TOP , BOTTOM, RIGHT, LEFT

How to align with css

I want to display my subtitles with unique style. So we use the following css code for style
.title-1 {
border-bottom: 1px solid #4db2ec;
margin-bottom: 10px;
padding-bottom: 4px;
position: relative;
font-size: 16px !important;
color: #FFF }
.title-1 > span {
background: #4db2ec;
width: auto;
padding: 4px 7px }
Now I am insert advertisement block with following html code with wrap text.
<div style="float: right; margin-left: 20px;">
<img src="http://domain.com/ad.jpg" height="600" width="160">
</div>
<h2 class="title-1"><span id="location">My Sub Title</span></h2>
now my title style is operlap in my advertisement block. how to solve this?
Here is a jsFiddle: http://jsfiddle.net/f025d5Lh/
Simplest is to add z-index:-999; to .title-1, this will push down the relative div below any div
Demo
CSS
.title-1 {
border-bottom:1px solid #4db2ec;
margin-bottom:10px;
padding-bottom:4px;
position:relative;
font-size:16px !important;
z-index:-999; /* only change */
color:#FFF
}
.title-1 > span {
background:#4db2ec;
width:auto;
padding:4px 7px
}

Position of the button is off on IE and FF

How do I match the style (and also the position is off) of the button on
http://jsfiddle.net/nA4P9/21/
using the compatible codes in CSS?
See image attached from different browsers - Chrome/IE/FF.
CSS -
.FindHome {background-color:#09F; width:300px; border:1px solid #09F; padding:10px 40px 10px 15px; border-radius:5px; display:block; margin-left:auto; margin-right:auto; background: #09F url('http://www.magnixsolutions.com/clients/tas/img/arrow.png') no-repeat; background-position:320px center; margin-bottom:35px; overflow: hidden; text-decoration:none; color:#ffffff;}
.FindHome:hover {border:1px solid #4d4d4d; background: #4d4d4d url('http://www.magnixsolutions.com/clients/tas/img/arrow.png') no-repeat; background-position:320px center;}
.FindHome-div{display:inline-block;}
HTML -
<div class="fluid FindHome-div">
<h1>Find your home </h1>
</div>

button not staying within div

I have a <div> and a <button>, but for some reason, the button will not stay in the div.
I have tried to clear the div, as well as float: left but it has not helped.
I have also added padding to the bottom of the div, but I don't think that is the solution.
My code:
<div class="service-text text2">
<p>
this is some text
</p>
<i class="fa fa-credit-card" style="padding-right:10px;"></i> Learn More
</div>
JSFiddle
Usually parent div set its height auto to its child heights, but padding you assigned to button-learn is causing the issue.
you just need to set display:inline-block; on your anchor tag
An inline-block element is placed as an inline element (on the same line as adjacent content), but it behaves as a block element.
.button-learn {
margin: 2px;
position:relative;
text-align: center;
border-radius:4px;
text-decoration: none;
font-family:'PT Sans',helvetica;
background: #69c773;
display:inline-block;
font-size: 17px !important;
padding: 10px 10px 10px 10px;
color: #FFF;
}
Here is fiddle
Floating both the elements seems to do what you want, unless you want the button to be next to the text.
add these:
.service-text {
float: left;
}
.button-learn {
float:left;
}
or check: http://jsfiddle.net/Milanzor/Qt9u3/4/
working demo
Set document height first:
body, html {
height:100%
}
then set .service-text height:
.service-text {
margin:0;
width:100%;
height:100%; /* change this from auto */
display:block;
background-color:#34495e;
-moz-border-radius: 0px;
-webkit-border-radius: 0px 0px 5px 5px;
border-radius: 0px 0px 5px 5px;
}
and it works!! :)
EDIT
div inside another div
HTML
<div id="parent">
<div class="service-text text2">
<p>this is some text</p>
<i class="fa fa-credit-card" style="padding-right:10px;"></i> Learn More
CSS
body, html {
height:100%;
margin:0;
padding:0;
}
#parent {
height:100%; /* remove this and everything falls out of place*/
}
.service-text {
margin:0;
width:100%;
height:100%;
display:block;
background-color:#34495e;
-moz-border-radius: 0px;
-webkit-border-radius: 0px 0px 5px 5px;
border-radius: 0px 0px 5px 5px;
}
.service p {
margin:0;
padding-top:5px;
padding-bottom:10px;
padding-right:7px;
padding-left:15px;
font-family:'PT Sans', 'Arial', 'Open Sans';
font-size:14px;
line-height:22px;
color:white;
display: block;
position:relative;
}
.button-learn {
margin: auto;
position:relative;
text-align: center;
border-radius:4px;
text-decoration: none;
font-family:'PT Sans', helvetica;
background: #69c773;
font-size: 17px !important;
padding: 10px 10px 10px 10px;
color: #FFF;
}
.button-learn:hover {
color: #51A65F;
}
</div>
</div>
Explaination : you just need to set the height of the div always, once you set it.....you'll get the desired view!

css : buttons float to the top. How do I align them horizontally?

I have the following css :
img { border-style : none }
a { text-decoration : none }
#header { width : 100%}
#header #topbar{width:705px;
padding:3px 10px 0 10px;
float:left;
height:30px;
line-height:22px;
background-color:#eee;
max-width:750px;
-moz-border-radius-bottomleft:3px;
-moz-border-radius-bottomright:3px;
-webkit-border-radius-bottom-left:3px;
-webkit-border-radius-bottom-right:3px;
}
#header #logo { height : 61px;
width : 250px;
float : left;
}
/* BUTTONS */
.buttons a, .buttons button{
display:block;
float:right;
margin:0 7px 0 0;
background-color:#E0EEEE;
border:1px solid #dedede;
border-top:1px solid #eee;
border-left:1px solid #eee;
font-family:"Lucida Grande", Tahoma, Arial, Verdana, sans-serif;
font-size:100%;
line-height:130%;
text-decoration:none;
font-weight:bold;
color:#565656;
cursor:pointer;
padding:5px 10px 6px 7px; /* Links */
}
.buttons button{
width:auto;
overflow:visible;
padding:4px 10px 3px 7px; /* IE6 */
}
.buttons button[type]{
padding:5px 10px 5px 7px; /* Firefox */
line-height:17px; /* Safari */
}
*:first-child+html button[type]{
padding:4px 10px 3px 7px; /* IE7 */
}
.buttons button img, .buttons a img{
margin:0 3px -3px 0 !important;
padding:0;
border:none;
width:16px;
height:16px;
}
/* POSITIVE */
button.positive, .buttons a.positive{
color:#529214;
}
.buttons a.positive:hover, button.positive:hover{
background-color:#E6EFC2;
border:1px solid #C6D880;
color:#529214;
}
.buttons a.positive:active{
background-color:#529214;
border:1px solid #529214;
color:#fff;
}
with the html code:
<body>
<div id="header">
<div id="topbar">
<div id="logo">
<a href="" >
<img src="images/logo-temp.png">
</a>
</div>
<div id= "buttons">
<div class="buttons">
<a href="/password/reset/" class="positive">
<img src="icons/arrow_up.png" alt=""/>
Send
</a>
<a href="/password/reset/" class="positive">
<img src="icons/arrow_down.png" alt=""/>
Receive
</a>
<a href="#" class="positive">
<img src="icons/user.png" alt=""/>
Users
</a>
</div>
</div>
</div>
Problem:
Right now the logo is floating left however the 3 buttons floating right but also horizontally aligned to the top. How do I fix this so all buttons are aligned to the bottom with the logo on the same line?
Add a margin to the button class to push the buttons down.
.buttons {margin-top:30px;}
Edit after comment
You want to add the margin to the <div class="buttons">
Put it right above .buttons a in the css.
/* BUTTONS */
.buttons {margin-top:30px;}
.buttons a, .buttons button{
...
}
#header #logo
{
height : 61px;
width : 100%;
float : left;
}
There's also an error in your CSS where you terminate the brackets twice after this declaration.
Reasoning:
Currently you're floating the #header #logo to the left but it doesn't fill it the width of its parent container, leaving space available on the right hand side. When you float the buttons they fall into this free space, so you need to fill it by increasing the left float to the full width.
JSBin, working demo.