3 Replies - 898 Views - Last Post: 13 March 2013 - 12:47 PM

#1 Log1ck  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 39
  • Joined: 22-January 13

CSS DIV Selection (Div id>div id) possible?

Posted 12 March 2013 - 11:07 PM

im trying to select a div that I have within another div. Right now the code goes something like this.

#content #news {
       
possible code here
}



Everything i do in that css selection just applies to the #content div rather than its child.

What would be a good way to do this?


DEEPER EXPLANATION IF NEEDED
----------------------------------------

Im trying to post an SQL update into the content box.

I am currently running this.

<div id="contenttop">
	 <img src="images/showcasetop.jpg"/><br />
</div>

<div id="content">

	 <img src="images/leftshowcase.jpg"/>
	 
	 	 			 <div id="news" style=background-image:url(images/showcasecontent.jpg)>
					 <?php
						 while ($row = mysql_fetch_assoc($query)){
	  					 ?>
	  					 <h2><a href="index.php?id=<?php echo $row['id']; ?>"> <?php echo $row['title']; ?> </a></h2>
	  					 <p> <?php echo $row['contents']; ?></p>
	  					 <?php
						 }
					 ?>
				 </div>	 
	 <img class="img2" src="images/showcaseimage.jpg"/>
	 <img class="img2" src="images/rightshowcase.jpg"/>
 </div>
 <div id="contentborder">
	 <img src="images/topleftcontent.jpg"/>
	 <img class="img" src="images/showcaserepeater.jpg"/>
	 <img class="img" src="images/toprightcontent.jpg"/>
</div>




When I run that code, i get this problem.
Posted Image

As you can see, the content box is off. So normally I would adjust the margin on it,
but this is not possible with the css im using. Suggestions would be helpful

Is This A Good Question/Topic? 0
  • +

Replies To: CSS DIV Selection (Div id>div id) possible?

#2 josefroyadvincula  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 23
  • Joined: 23-December 12

Re: CSS DIV Selection (Div id>div id) possible?

Posted 13 March 2013 - 06:31 AM

you can actually just do

#news {
code here
}

since you are targeting a div with an ID
Was This Post Helpful? 0
  • +
  • -

#3 Log1ck  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 39
  • Joined: 22-January 13

Re: CSS DIV Selection (Div id>div id) possible?

Posted 13 March 2013 - 08:53 AM

When I edit the top margin of news i get this:

#news {
      margin-top:10px;
      display:inline-block;
      height:273px;
      width:540px;
      }   



As you can see, it pushed the whole width down, instead of just the block im selecting.

Posted Image
Was This Post Helpful? 0
  • +
  • -

#4 Koyume  Icon User is offline

  • D.I.C Head

Reputation: 15
  • View blog
  • Posts: 89
  • Joined: 19-February 13

Re: CSS DIV Selection (Div id>div id) possible?

Posted 13 March 2013 - 12:47 PM

One, remove the style=background item. You can do that via CSS.

And inside the container, you have to use padding-top: 10px; Try that and see how that goes. Put your background item inside the #news CSS.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1