Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,148,784 members, 7,802,436 topics. Date: Friday, 19 April 2024 at 02:24 PM

How Can I Nest CSS Selectors To Achieve This?(photos) - Webmasters - Nairaland

Nairaland Forum / Science/Technology / Webmasters / How Can I Nest CSS Selectors To Achieve This?(photos) (416 Views)

Webmasters How Can I Achieve This / Pseudo Class Selectors Vs Pseudo Element Selectors / Please How Can I Achieve This With Php (2) (3) (4)

(1) (Reply) (Go Down)

How Can I Nest CSS Selectors To Achieve This?(photos) by Drella(m): 11:09am On Dec 14, 2020
Hello webmasters.I just decided to build my first project with the knowledge of HTML and CSS I have garnered.

Now,I am building an e-fashion store where different fashion sections are displayed on the index page.I want any section I hover on to increase in height and width and go back to its original size when it is no more hovered on.
I grouped the various sections in a div tag with a class "sect".In each div tag contains a figure tag that houses the img tag and a figcaption tag to hold a description text of the image.

My problem:
I gave the "div.sect" selector a " :hover" pseudo-class with the property being an increment in size of the div.when I ran the code,I noticed it formed only a box outside the figure tag with a lot of white space inside it.The image size remained the same
.I tried putting the " :hover" on img alone,whenever I hover on the image alone,it increases in size but if I hover on the caption,there will be no effect.I even tried with the figure tag and different variations but all to no avail.

My question:
I know CSS is not a programming language but can't I nest the selectors like this or something related?:

if div.sect:hover {
width:***px;
height:***px;
--- img {
--- width:**px;
--- height:**px;
}
--- figcaption {
--- font-size:**px;
}
}

Meaning if div.sect gets hovered on,it should activate these specified properties grin


img 1:Section not hovered.
img 2:A hovered section.
img 3:The CSS rules.


modified:
Nairaland isn't making the indentation of the supposed nesting visible.So I replaced the spaces with dashes.

Re: How Can I Nest CSS Selectors To Achieve This?(photos) by etoluw: 12:31pm On Dec 14, 2020
try this
div.sect:hover img { .... }
Re: How Can I Nest CSS Selectors To Achieve This?(photos) by Drella(m): 1:26pm On Dec 14, 2020
etoluw:
try this

div.sect:hover img { .... }
Thanks

But I don't know how that might be it because,I want to assign a property for that div too.
I.e
div.sect:hover{....}
How can I place the img in the above rule??
Re: How Can I Nest CSS Selectors To Achieve This?(photos) by etoluw: 2:31pm On Dec 14, 2020
Drella:

Thanks

But I don't know how that might be it because,I want to assign a property for that div too.
I.e
div.sect:hover{....}
How can I place the img in the above rule??

use div.sect:hover for the div
Re: How Can I Nest CSS Selectors To Achieve This?(photos) by Drella(m): 3:38pm On Dec 14, 2020
etoluw:


use div.sect:hover for the div

It will only create a box around it,the image won't expand with it.
Check image 2 posted above.

(1) (Reply)

1 Year Old Ads Limit Nigeria Adsense For Sale / Legit Coin98 Wallet Airdrop / How To Stop Spam Registration In Php

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 12
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.