TvCasteren
TvCasteren

Reputation: 425

Change position of <div> in <div class>

I am looking to change the position of a div that is inside a div class. My only option is to add CSS, I cannot edit the HTML. The current code looks like this:

<div class="additional-information">
 <div>
 <strong> Name </strong>
 <strong> Address </strong>
</div>

What I managed to do is to change the position of the entire 'additional-information' class with the following code:

    .additional-information {
  position: absolute;
  left: 250px;
  bottom: -230px;
  }

Would it be possible to move individual divs inside this class that have no tag?

Upvotes: 0

Views: 726

Answers (1)

iamlordsandro
iamlordsandro

Reputation: 461

You could work with CSS Child Selector.

Something like this:

.additional-information > div:nth-of-type(1) {
  position: absolute;
  left: 250px;
  bottom: -230px;
  background-color: lightblue;
}
<div class="additional-information">
  I am a parent
    <div>
      <strong>name</strong>
      <strong>address</strong>
    </div>
</div>

For more info look at this article.

Upvotes: 1

Related Questions