Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / NewStats: 3,225,106 members, 8,062,025 topics. Date: Saturday, 25 January 2025 at 05:18 PM |
Nairaland Forum / Science/Technology / Webmasters / How Can I Nest CSS Selectors To Achieve This?(photos) (469 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)
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 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: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: 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: It will only create a box around it,the image won't expand with it. Check image 2 posted above. |
(1) (Reply)
Best Free Article Rewriter/spinner 2021 / How To Get More Views On Your Whatsapp TV (working Trick) / Help: I Need A Wordpress Website With Login, Registration And User Dashboard
(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 - 2025 Oluwaseun Osewa. All rights reserved. See How To Advertise. 25 |