CSS Div alignment

Hello Experts,

The page has a <Div> with
'position: relative; top: 15px;'
a second  <Div> with
'position: relative; top: 15px;'

I thought they would be aligned
vertically as shown in gif marked
'Div alignment wanted"

Instead it places the second div below
the first as in  gif marked
'Div alignment existing"

I tried using 'z-index' to separate them
but no luck.

How can I get the two blocks to be the sane distance from
the top?


Allen in Dallas

+++++++++++begin code++++++++++++++++++++
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">`
<title> Div stack </title>
<style type="text/css">
div {font-family:arial; color:sienna;}
<div style = "background-color: #004280; color: #FFFFFF; width: 100%; height: 130px; text-align: center; margin-left: auto; margin-right: auto;">

<div id="cmsDateTime" style = "margin-left: auto; margin-right: auto; width: 200px; text-align: center; color: white; position: relative; top: 15px; background-color: #0B7CE5;">
WriteDate text</div>
<div style = "float: right; color: white; position: relative; top: 15px; background-color: #66B3FA; width: 350px; z-index:100;">
UserName text


+++++++++++end code++++++++++++++++++++
Allen PittsBusiness analystAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Add display: inline-block; to the first div
And change margin-right to -350px

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Allen PittsBusiness analystAuthor Commented:
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.