Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Update css property of a child element in specific div

Tags:

html

css

jsp

styles

I have 2 different div containers in my same jsp file for which i dont have access to edit.

--Div 1

<div class="mar-t40 alignRight">
    <img id="ts_fclogoBox" alt="Logo" src="{{imgPath}}/content/dam/Logo.png" />
</div>

--Div 2

<div class="alignRight">
    <img id="ts_fclogoBox" alt="Logo" src="{{imgPath}}/content/dam/Logo.png" />
</div>

Now i need to apply the below css only to ts_fclogoBox present inside DIV 2. Is it possible to achieve it without editing the jsp file ?

#ts_fclogoBox {
    margin-left: -15px;
}

I feel that is impossible but just wanted to see whether is there some way.

like image 691
Dinesh Kumar Avatar asked Sep 16 '25 19:09

Dinesh Kumar


2 Answers

Use class and ids to avoid confusion with other divs

div.alignRight:nth-child(2) img#ts_fclogoBox{
  margin-left:-15px;
}
like image 160
philantrovert Avatar answered Sep 19 '25 11:09

philantrovert


you can acheive that by using child selector in css3

div:nth-child(2) img {
     margin-left: -15px;
}
like image 28
Akshay Avatar answered Sep 19 '25 10:09

Akshay