Reputation: 1037
So, here is my problem; I am trying to position a div
that is right next to a table
. I want them to line up side by side. Like it is, they line up with the text above all of the rest of it. Check out my vision board below:
Except I actually want the words "Signature Editor" to be at the top (photo problem) rather than the bottom. So that is what I want. It all to be lined up side by side. However, here is what is actually is:
As you can see, the "Signature Editor" text is above the table rather than lined up like how I want it to be (see my vision board).
Here is my code:
table {
display: inline-block;
}
#signatureEditorText {
font-family: 'Source Sans Pro', sans-serif;
}
#image {
width: 125px;
height: 125px;
border-radius: 50%;
margin-top: -45px;
}
.spacer {
width: 15px;
}
hr {
height: 200px;
width: 7.5px;
border-radius: 20px;
border: none;
background-color: cornflowerBlue;
}
#fullName {
font-family: 'Source Sans Pro', sans-serif;
font-size: 20px;
color: orange;
margin-top: -40px;
}
#job {
font-family: 'Source Sans Pro', sans-serif;
font-size: 15px;
margin-top: -12px;
}
#jobLocationText {
font-family: 'Source Sans Pro', sans-serif;
font-size: 14px;
margin-top: -3px;
}
.otherText {
color: seaGreen;
}
#emailAddress {
margin-top: 5px;
}
#extra1, #extra2, #extra3, #extra4, #extra5, #extra6 {
white-space: pre-wrap;
}
<div id = "signatureEditorText"><h2>Signature Editor</h2></div>
<table cellpadding="0" cellspacing="0" border="0" style="background: none; border-width: 0px; border: 0px; margin: 0; padding: 0;">
<tr>
<td>
<img src = "https://vignette2.wikia.nocookie.net/mafiagame/images/2/23/Unknown_Person.png/revision/latest?cb=20151119092211" id = "image" title = "Picture to be displayed">
</td>
<td class = "spacer"></td>
<td rowspan = "4">
<hr>
</td>
<td class = "spacer"></td>
</tr>
<tr>
<td><center><div id = "fullName">Billy Staples</div></center></td>
</tr>
<tr>
<td><center><div id = "job"><i>Programmer</i></div></center></td>
</tr>
<tr>
<td><center><div id = "jobLocationText">at <b id = "jobLocation">My Company</b></div></center></td>
</tr>
</table>
<table id = "contactInfo" cellpadding="0" cellspacing="0" border="0" style="background: none; border-width: 0px; border: 0px; margin: 0; padding: 0;">
<tr>
<td><div id = "emailAddress"><span class = "otherText">Email: </span><span id = "emailAddressText">[email protected]</span></div></td>
</tr>
<tr>
<td><div id = "phoneNumber"><span class = "otherText">Phone: </span><span id = "phoneNumberFirst">111</span>-<span id = "phoneNumberSecond">222</span>-<span id = "phoneNumberThird">3333</span></div></td>
</tr>
<tr>
<td><div id = "officePhoneNumber"><span class = "otherText">Office Phone: </span><span id = "officePhoneNumberFirst">444</span>-<span id = "officePhoneNumberSecond">555</span>-<span id = "officePhoneNumberThird">6666</span></div></td>
</tr>
<tr>
<td><div id = "address"><span class = "otherText">Address: </span><span id = "addressText">1379 Philadelphia Avenue</span></div></td>
</tr>
<tr>
<td><div id = "website"><span class = "otherText">Website: </span><span id = "websiteText">example.com</span></div></td>
</tr>
<tr>
<td><div id = "extra1"><span class = "otherText" id = "extra1Label"></span><span id = "extra1Text"> </span></div></td>
</tr>
<tr>
<td><div id = "extra2"><span class = "otherText" id = "extra2Label"></span><span id = "extra2Text"> </span></div></td>
</tr>
<tr>
<td><div id = "extra3"><span class = "otherText" id = "extra3Label"></span><span id = "extra3Text"> </span></div></td>
</tr>
<tr>
<td><div id = "extra4"><span class = "otherText" id = "extra4Label"></span><span id = "extra4Text"> </span></div></td>
</tr>
<tr>
<td><div id = "extra5"><span class = "otherText" id = "extra5Label"></span><span id = "extra5Text"> </span></div></td>
</tr>
<tr>
<td><div id = "extra6"><span class = "otherText" id = "extra6Label"></span><span id = "extra6Text"> </span></div></td>
</tr>
</table>
And a JSFiddle of it is here.
Also, here are some methods I have tried: display: inline;
, display: inline-block;
, display: block;
.
Thanks!
Upvotes: 0
Views: 32
Reputation: 53664
I would make the parent display: flex;
to put the 2 elements in a row, aligned to flex-start
by default, then add margin: 0
to the h2
body {
display: flex;
}
h2 {
margin: 0;
}
table {
display: inline-block;
}
#signatureEditorText {
font-family: 'Source Sans Pro', sans-serif;
}
#image {
width: 125px;
height: 125px;
border-radius: 50%;
margin-top: -45px;
}
.spacer {
width: 15px;
}
hr {
height: 200px;
width: 7.5px;
border-radius: 20px;
border: none;
background-color: cornflowerBlue;
}
#fullName {
font-family: 'Source Sans Pro', sans-serif;
font-size: 20px;
color: orange;
margin-top: -40px;
}
#job {
font-family: 'Source Sans Pro', sans-serif;
font-size: 15px;
margin-top: -12px;
}
#jobLocationText {
font-family: 'Source Sans Pro', sans-serif;
font-size: 14px;
margin-top: -3px;
}
.otherText {
color: seaGreen;
}
#emailAddress {
margin-top: 5px;
}
#extra1,
#extra2,
#extra3,
#extra4,
#extra5,
#extra6 {
white-space: pre-wrap;
}
<div id="signatureEditorText">
<h2>Signature Editor</h2></div>
<table cellpadding="0" cellspacing="0" border="0" style="background: none; border-width: 0px; border: 0px; margin: 0; padding: 0;">
<tr>
<td>
<img src="https://vignette2.wikia.nocookie.net/mafiagame/images/2/23/Unknown_Person.png/revision/latest?cb=20151119092211" id="image" title="Picture to be displayed">
</td>
<td class="spacer"></td>
<td rowspan="4">
<hr>
</td>
<td class="spacer"></td>
</tr>
<tr>
<td>
<center>
<div id="fullName">Billy Staples</div>
</center>
</td>
</tr>
<tr>
<td>
<center>
<div id="job"><i>Programmer</i></div>
</center>
</td>
</tr>
<tr>
<td>
<center>
<div id="jobLocationText">at <b id="jobLocation">My Company</b></div>
</center>
</td>
</tr>
</table>
<table id="contactInfo" cellpadding="0" cellspacing="0" border="0" style="background: none; border-width: 0px; border: 0px; margin: 0; padding: 0;">
<tr>
<td>
<div id="emailAddress"><span class="otherText">Email: </span><span id="emailAddressText">[email protected]</span></div>
</td>
</tr>
<tr>
<td>
<div id="phoneNumber"><span class="otherText">Phone: </span><span id="phoneNumberFirst">111</span>-<span id="phoneNumberSecond">222</span>-<span id="phoneNumberThird">3333</span></div>
</td>
</tr>
<tr>
<td>
<div id="officePhoneNumber"><span class="otherText">Office Phone: </span><span id="officePhoneNumberFirst">444</span>-<span id="officePhoneNumberSecond">555</span>-<span id="officePhoneNumberThird">6666</span></div>
</td>
</tr>
<tr>
<td>
<div id="address"><span class="otherText">Address: </span><span id="addressText">1379 Philadelphia Avenue</span></div>
</td>
</tr>
<tr>
<td>
<div id="website"><span class="otherText">Website: </span><span id="websiteText">example.com</span></div>
</td>
</tr>
<tr>
<td>
<div id="extra1"><span class="otherText" id="extra1Label"></span><span id="extra1Text"> </span></div>
</td>
</tr>
<tr>
<td>
<div id="extra2"><span class="otherText" id="extra2Label"></span><span id="extra2Text"> </span></div>
</td>
</tr>
<tr>
<td>
<div id="extra3"><span class="otherText" id="extra3Label"></span><span id="extra3Text"> </span></div>
</td>
</tr>
<tr>
<td>
<div id="extra4"><span class="otherText" id="extra4Label"></span><span id="extra4Text"> </span></div>
</td>
</tr>
<tr>
<td>
<div id="extra5"><span class="otherText" id="extra5Label"></span><span id="extra5Text"> </span></div>
</td>
</tr>
<tr>
<td>
<div id="extra6"><span class="otherText" id="extra6Label"></span><span id="extra6Text"> </span></div>
</td>
</tr>
</table>
Upvotes: 0
Reputation: 42304
So you want your text to be displayed to the left of your table, and at the top, so that it lines up with the avatar? That can be achieved by simply setting float: left
on the #signatureEditorText
:
table {
display: inline-block;
}
#signatureEditorText {
font-family: 'Source Sans Pro', sans-serif;
float: left;
}
#image {
width: 125px;
height: 125px;
border-radius: 50%;
margin-top: -45px;
}
.spacer {
width: 15px;
}
hr {
height: 200px;
width: 7.5px;
border-radius: 20px;
border: none;
background-color: cornflowerBlue;
}
#fullName {
font-family: 'Source Sans Pro', sans-serif;
font-size: 20px;
color: orange;
margin-top: -40px;
}
#job {
font-family: 'Source Sans Pro', sans-serif;
font-size: 15px;
margin-top: -12px;
}
#jobLocationText {
font-family: 'Source Sans Pro', sans-serif;
font-size: 14px;
margin-top: -3px;
}
.otherText {
color: seaGreen;
}
#emailAddress {
margin-top: 5px;
}
#extra1, #extra2, #extra3, #extra4, #extra5, #extra6 {
white-space: pre-wrap;
}
<div id = "signatureEditorText"><h2>Signature Editor</h2></div>
<table cellpadding="0" cellspacing="0" border="0" style="background: none; border-width: 0px; border: 0px; margin: 0; padding: 0;">
<tr>
<td>
<img src = "https://vignette2.wikia.nocookie.net/mafiagame/images/2/23/Unknown_Person.png/revision/latest?cb=20151119092211" id = "image" title = "Picture to be displayed">
</td>
<td class = "spacer"></td>
<td rowspan = "4">
<hr>
</td>
<td class = "spacer"></td>
</tr>
<tr>
<td><center><div id = "fullName">Billy Staples</div></center></td>
</tr>
<tr>
<td><center><div id = "job"><i>Programmer</i></div></center></td>
</tr>
<tr>
<td><center><div id = "jobLocationText">at <b id = "jobLocation">My Company</b></div></center></td>
</tr>
</table>
<table id = "contactInfo" cellpadding="0" cellspacing="0" border="0" style="background: none; border-width: 0px; border: 0px; margin: 0; padding: 0;">
<tr>
<td><div id = "emailAddress"><span class = "otherText">Email: </span><span id = "emailAddressText">[email protected]</span></div></td>
</tr>
<tr>
<td><div id = "phoneNumber"><span class = "otherText">Phone: </span><span id = "phoneNumberFirst">111</span>-<span id = "phoneNumberSecond">222</span>-<span id = "phoneNumberThird">3333</span></div></td>
</tr>
<tr>
<td><div id = "officePhoneNumber"><span class = "otherText">Office Phone: </span><span id = "officePhoneNumberFirst">444</span>-<span id = "officePhoneNumberSecond">555</span>-<span id = "officePhoneNumberThird">6666</span></div></td>
</tr>
<tr>
<td><div id = "address"><span class = "otherText">Address: </span><span id = "addressText">1379 Philadelphia Avenue</span></div></td>
</tr>
<tr>
<td><div id = "website"><span class = "otherText">Website: </span><span id = "websiteText">example.com</span></div></td>
</tr>
<tr>
<td><div id = "extra1"><span class = "otherText" id = "extra1Label"></span><span id = "extra1Text"> </span></div></td>
</tr>
<tr>
<td><div id = "extra2"><span class = "otherText" id = "extra2Label"></span><span id = "extra2Text"> </span></div></td>
</tr>
<tr>
<td><div id = "extra3"><span class = "otherText" id = "extra3Label"></span><span id = "extra3Text"> </span></div></td>
</tr>
<tr>
<td><div id = "extra4"><span class = "otherText" id = "extra4Label"></span><span id = "extra4Text"> </span></div></td>
</tr>
<tr>
<td><div id = "extra5"><span class = "otherText" id = "extra5Label"></span><span id = "extra5Text"> </span></div></td>
</tr>
<tr>
<td><div id = "extra6"><span class = "otherText" id = "extra6Label"></span><span id = "extra6Text"> </span></div></td>
</tr>
</table>
Hope this helps! :)
Upvotes: 1