Semantic-ui: [Sidebar] Wrong size of pusher when visible

Created on 17 Nov 2015  路  10Comments  路  Source: Semantic-Org/Semantic-UI

Hello,

If I use the same code as provided in your jsFiddle posted on issue [Sidebar] Allow Sidebar to Start Visible #649. the pusher div as the same width than the body without substracting the sidebar width.
This issue is also available in your jsFiddle examples.
How can I have the right width of the pusher div if my sidebar is visible on load ?

Duplicate

Most helpful comment

Semantic-ui doc says "A sidebar can be visible on the page. To have a sidebar appear on page load simply add the class visible to the sidebar.". However, when it renders on screen, the content is too far to the right. Please fix this issue.

All 10 comments

JSFiddle that describes the bug: https://jsfiddle.net/Kpblca4/vnsyavwp/

I also have a similar problem when trying to have a .ui.container inside a .pusher:
http://jsfiddle.net/rto3b0ab/

The .grid > .column can be taken out, it's there for contrasting the container behaviour.

The temporary workaround was to use this as a pusher:

<div class="pusher" style="width: calc(100% - 150px);">

where 150px is the thin sidebar size.

I noticed the same issue today

Me too. Any approach that doesn't involve hacking the CSS of Semantic UI?

Can confirm @andreicojocaru workaround works.

It鈥檚 been a while, I explained it here; closing as a duplicate. If anyone has some questions, I鈥檒l be happy to answer them either in this thread, or in our Gitter chatroom.

@Banandrew my use case is that I want the sidebar collapsed by default on mobile/small screens, and the same sidebar should be always open/static on large screens. I currently use media queries to change the size class as well, but I can't do that to change whether it's static/pinned or not. What do you recommend for that? Can it work with your flexbox jsfiddle example?

@xtagon I think there鈥檙e several ways to go here depending on what UI pattern you鈥檙e trying to achieve.

If your sidebar should look like it鈥檚 attached to a page (like SUI鈥檚 documentation), then you can just follow the documentation and create 2 identical sidebars: one will be showing on computer screens and using the same Flexbox pattern as my JSFiddle, the other will be showing only on mobile screens and using the overlaying sidebar component. Resize the documentation to see how it transitions between the two鈥攂asically, the desktop sidebar becomes hidden at some breakpoint, and when it does, a button that toggles the mobile sidebar appears.

If your content is centered like here on GitHub, and if it won鈥檛 be hidden on computer screens under the overlaying sidebar when it鈥檚 shown, you can just automatically show it on such screens, something like that might work:

if ($(window).width() > 768) {
  $('.left.sidebar')
    .sidebar('show')
}

If you show me how it鈥檚 supposed to look, I might be more specific.

@Banandrew Actually what I want is exactly how it works on the SUI documentation. Hides only on mobile, and doesn't use the pusher on desktop. That should get me started. Thanks!

Semantic-ui doc says "A sidebar can be visible on the page. To have a sidebar appear on page load simply add the class visible to the sidebar.". However, when it renders on screen, the content is too far to the right. Please fix this issue.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Morrolan picture Morrolan  路  3Comments

miguelmota picture miguelmota  路  3Comments

mixerp picture mixerp  路  3Comments

larsbo picture larsbo  路  3Comments

davialexandre picture davialexandre  路  3Comments