I need help centering my table of content
I have no idea why my table of content won't center for the media query that I set up.
I have tried
display: flex; justify-content: center; align-items: center;
I also tried margin-right: auto; marigin-left: auto;
I put up a border around my class "dropdown" class to see if it spanned across the entire screen horizontally and it did. So it confuses me why margin auto or flexbox is not working for me? Any help would be appreciated.
https://blogbydave.netlify.app/blog/2024-10-30-virtualization/
https://github.com/DaveSamuels1998/Dave-Samuels-Blog
GitHub
GitHub - DaveSamuels1998/Dave-Samuels-Blog
Contribute to DaveSamuels1998/Dave-Samuels-Blog development by creating an account on GitHub.
5 Replies
it looks centered in the space to me?
although you probably want to add a flex-direction : column
I want the button to be only centered horizontally. Then have the dropdown push content downward with its margin. I am not sure if what is inside the button is causing it to act like this.
So you have an aria-expanded but no Aria-controls or controlledby. What is inside the button is only the words "Table of Contents". It has no children other than that node.
The parent .dropdown has two direct children .btn-link and .dropdown-menu
Since .dropdown has a display of flex, it's putting its two direct children side by side. Try flex-direction and see if that's what you're looking for.
Flex-direction makes the content get pushed down regardless if I click the button or not. The table of content is centered but I also want it to take up its respective space. I want the button to not take up space when the Table of Content is closed and push the content down when it is open.
I am using this site as a reference.
I want my Table of Contents to behave like this one in mobile view
https://moderncss.dev/providing-type-definitions-for-css-with-at-property/
Modern CSS Solutions
Providing Type Definitions for CSS with @property | Modern CSS Solu...
Write safer CSS using
@property
, which enables defining types for custom properties. Learn why traditional fallback values can fail, and how @property
features improve the resilience of custom property definitions.this one isnt centered on mobile view fyi.
Looks like you did a whole refactor.
if youre going to use a details/summary, you no longer need to use the button, its already an interactive element. And then is confusing with two focus jumps, one to the summary, and then another to the button inside which no longer needs to trigger anything
Which means you can completely get rid of your Javascript file that's using the button to toggle a .dropdown element since you're using the semantic details/summary instead , and don't forget to also remove the button element and just leave the text node Table of Contents