5

I have been working on re-doing my fathers website that was created in the nineties (ugh) and I have been having trouble getting the text to fit inside of a div and align horizontally. I need the text to sit next to each other so they fit in the div. Here's the code for the page in a jsfiddle

Example HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<body>
    <div> 
        <img id="header" src="http://www.salesprofessionalsinc.com/images/new%20logo.jpg">
    </div>
    <div id="links">
        <div class="home">
            <a href="index.html"><span></span>Home</a>
        </div>
        <div class="home">
            <a href="insidestaff.html"><span></span>Inside Staff</a>
        </div>
        <div class="home">
            <a href="mission.html"><span></span>Our Mission</a> 
        </div>
    </div>

Example CSS

div img#header{
    width: 50%;
    height: 15%;
    margin-left: 125px;
    margin-right: auto;
}center input#search{
    width: 300px;
    height: 45px;
    border: solid 1px black;
    margin-top: 55px;
    font-size: 25px;
}center button#searchbutt{
    border: solid 1px black;
    width: 65px;
    height: 30px;
}#searchbutt:hover{
    color: #FFF;
    background-color: #000;
}#searchbutt{
    background-color: #FFF;
    color: #000;
}#links{
    height: 40px;
    width: 100%;
    text-align: center;
    line-height: 40px;
}.home{
    width: 80px;
    text-align: center;
    height: 40px;
    background-color: white;
    color: black;
    padding-left: auto;
    padding-right: auto;
    display: inline-block;
    border: solid 1px black;
    vertical-align: middle;
}.DL{
    width: 95;
    text-decoration: none;
    text-align: center;
    height: 40px;
    background-color: white;
    color: black;
    padding-left: auto;
    padding-right: auto;
    display: inline-block;
    border: solid 1px black;
}.home a{
    text-decoration: none;
    color: gray;
}.DL a{
    text-decoration: none;
    color: gray;
}div center a#DLbutt{
    border: solid 1px black;
    width: 100px;
    height: 50px;
    background-color: black;
}div center a#DLbutt{
    text-decoration: none;
    color: gray;
}#download{
    padding-top: 30px;
}html{
     background-image: url("watermark.gif");
}.home a span{
     position:absolute; 
     width:100%;
     height:100%;
     top:0;
     left: 0;
     display: inline-block;
     vertical-align: middle;
     line-height: normal;
}

I need the "Our Mission part" to be in the same div.

2 Answers2

0

You need to set the display to be display: table-cell for div.home and then remove the line-height you have set for these. This should automatically align the text for you.

div img#header {
    width: 50%;
    height: 15%;
    margin-left: 125px;
    margin-right: auto;
}
#links {
    height: 40px;
    margin-left: 125px;
    text-align: center;
    display: inline-block;
}
.home {
    width: 80px;
    text-align: center;
    height: 40px;
    background-color: white;
    color: black;
    padding-left: auto;
    padding-right: auto;
    display: table-cell;
    border: solid 1px black;
    vertical-align: middle;
}
.home a {
    text-decoration: none;
    color: gray;
}

http://jsfiddle.net/03syn1to/

UsainBloot
  • 806
  • 6
  • 20
-3

I believe this is what you are asking for. You want the "Our Mission" to be in the button vertically. Just update with this code. And it should work. Let me know what you think.

.home{
   width: 80px;
   text-align: center;
   height: relative;
   background-color: white;
   color: black;
   padding-left: auto;
   padding-right: auto;
   display: inline-block;
   border: solid 1px black;
   vertical-align: middle;
}

I changed the height.. height: relative;

kamal
  • 192
  • 1
  • 8