The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

> Trouble applying css to an svg graphic
Brian Chandler
post Oct 23 2021, 06:05 AM
Post #1


Jocular coder
********

Group: Members
Posts: 2,460
Joined: 31-August 06
Member No.: 43



Please look at test page: https://imaginatorium.com/test.html
All the (relevant) javascript and css is included.

The top bit is a test of my "Destination"dropdown box.

div: blip is the box containing a bit of Italian and a pink box. It has *position: relative*, which I believe makes it css:positioned. (All css (mis)terminolog preceded thus)

div: blop has a pink background; includes the pulldown triangle at the right. Click this to display the dropdown.

(If you go somewhere else in the shop, like https://imaginatorium.com/aki.html (or if you have visited before) you can enter a destination which will appear in the pink box. "testdrop" is really "destdrop"... name changed to make it independent.)

The dropdown is div:testdrop, which I believe is an immediate child of div:blip. It has position css:absolute, which I believe means relative to the nearest enclosing css:positioned element.

CODE

    /* dropdown menu */
#testdrop {
    position: absolute;
    top: 0px;
    right: 0px;
...


According to everything I have read, this should mean that the dropdown is positioned exactly in the top right corner of div:blip. But it isn't.

But the real problem is the 'X' for closing the dropdown. Any css I apply to the svg itself seems to be ignored. The inspector thingy shows it in the list of css, without any sort of complaint, but refuses to show anything at all about the svg element (the 'X') itself. So I put it inside a div, and applied positioning to this div:

CODE

DIV.svgx {
    position: absolute;
    margin: 0;
    border: none;
    padding: 0;
    height: 12px;
    width: 12px;
    top: 10px;
    right: 10px;
border: solid thin #ff66ff;
}


This seems to be positioned correctly, but the svg element is 12x12 pixels. So why does it occupy a rectangle about 12x20 pixels. (Previously, I did not specify the height of div:svgx, and the div automatically sat around the 'X', with n pixels of padding top and bottom. But the padding is set to 0, as is margin.

Can anyone see why this (div version) is behaving like this, and can anyone tell me why I cannot seem to apply any css to the svg element itself.

Sorry if this seems scrappy: it has taken me something like an hour just to cut all the bits out of various included JS and css files. Grateful for help.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
 
Reply to this topicStart new topic
Replies
Christian J
post Nov 21 2021, 08:26 PM
Post #2


.
********

Group: WDG Moderators
Posts: 9,661
Joined: 10-August 06
Member No.: 7



In the CSS:

CODE
top: 20;
left: 20;

User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Posts in this topic
Brian Chandler   Trouble applying css to an svg graphic   Oct 23 2021, 06:05 AM
pandy   Not if you later tell it to be somewhere else. ...   Oct 23 2021, 07:47 PM
Brian Chandler   Thanks Pandy. I must have been tired, and yes that...   Oct 24 2021, 12:26 AM
pandy   You've made div.svgx 20px high. You don't ...   Oct 24 2021, 05:52 AM
Brian Chandler   You've made div.svgx 20px high. You don't...   Oct 25 2021, 06:11 AM
pandy   This is true, but it doesn't explain anything...   Oct 25 2021, 12:55 PM
Brian Chandler   [quote name='Brian Chandler' post='142731' date='...   Oct 25 2021, 02:14 PM
pandy   I don't understand. Which is the pink DIV? The...   Oct 25 2021, 03:32 PM
Brian Chandler   I don't understand. Which is the pink DIV? Th...   Oct 25 2021, 11:41 PM
pandy   Yes, you are right. I got confused by the differen...   Oct 26 2021, 12:45 AM
pandy   I only used the inspector, but when I look at the ...   Oct 26 2021, 01:07 AM
Brian Chandler   Yes, you are right. I got confused by the differe...   Oct 26 2021, 12:26 PM
pandy   OK, lets leave it at that then.   Oct 26 2021, 03:06 PM
Christian J   Brian, I didn't look closely at the linked p...   Oct 26 2021, 05:53 PM
Brian Chandler   Thanks to both of you for looking at this. Basical...   Oct 30 2021, 11:51 AM
Christian J   But I was slightly intrigued by Christian's e...   Oct 30 2021, 04:28 PM
Brian Chandler   [quote name='Brian Chandler' post='142763' date='...   Nov 21 2021, 02:51 PM
Christian J   In the CSS: top: 20; left: 20;   Nov 21 2021, 08:26 PM


Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 27th April 2024 - 03:26 AM