Home > Mobile >  Change position of <div> in <div class>
Change position of <div> in <div class>

Time:05-22

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 >
 <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?

CodePudding user response:

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 >
  I am a parent
    <div>
      <strong>name</strong>
      <strong>address</strong>
    </div>
</div>

For more info look at this article.

  •  Tags:  
  • css
  • Related