Solved

Why does this div not display correctly?

Posted on 2013-11-27
3
208 Views
Last Modified: 2013-11-27
Head out to http://www.brucegust.com/drummerboy

I want the youtube video that's belligerently lurking at the bottom of the screen to be positioned where the youtube graphic is.

I've got the graphic positioned "relative" and the youtube div is "absolute," but I can't get the two to cooperate.

What am I doing wrong?

Here's my stylesheet:

body {
	font-family: Helvetica, Microsoft Sans Serif;
	font-size: 14px;
	color: #000000;
	vertical-align: top;
	height: 100%;
	width: 100%;
	margin-top:25px;
	background-color:#ffffff;
}


#graphic {
position:relative;
height:934px;
width:1085px;
text-align:center;
margin:auto;
}

#youtube {
position:absolute;
height:319px;
width:460px;
margin-left:579px;
margin-top:176px;
z-index:2;
}



		










		

Open in new window

0
Comment
Question by:brucegust
  • 2
3 Comments
 
LVL 43

Expert Comment

by:Chris Stanyon
ID: 39681516
You're positioning your #youtube DIV absolutely so you need to tell it where to sit. Because you already have margins in place, just add top: 0; to the rule and it'll be fine:

#youtube {
    height: 319px;
    margin-left: 579px;
    margin-top: 176px;
    position: absolute;
    top: 0;
    width: 460px;
    z-index: 2;
}

Open in new window

0
 
LVL 43

Accepted Solution

by:
Chris Stanyon earned 500 total points
ID: 39681535
A better solution may be to remove the margins altogether and just position the DIV

#youtube {
    height: 319px;
    left: 579px;
    top: 176px;
    position: absolute;
    width: 460px;
    z-index: 2;
}

Open in new window

0
 

Author Comment

by:brucegust
ID: 39681589
That'll do it!
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Bootstrap list items overlap 3 36
Fix Form size HTML 16 31
Can't get cursor to change 3 16
HTML question 2 26
When writing CSS, there are a few simple rules that will make your life easier.    1. Using ‘* {box-sizing:border-box;}’. Using this will wrap all your elements in a nice little compact box-model that will give you the width you want, like so... …
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
In this tutorial viewers will learn how to customize the background color and font color of highlighted text using the ::selection element in CSS Begin by defining the selected text as an element in CSS by typing "::selection": Style the ::selection…
In this tutorial viewers will learn how to style different bullet points for unordered lists in CSS. Begin with a normal unordered list; the default bullet point is a solid circle: In the CSS, create a defined class of unordered list by typing "ul.S…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question