Move "main" content right for side menu
Permalink Browser Info Environment
Trying to make a side navigation menu, and am basing the code off what I found here:http://www.w3schools.com/howto/tryit.asp?filename=tryhow_js_sidenav...
I placed the above code for the side menu in the global "Sitewide Site Name" block and the menu behaves fine. However, when I can't get the "main" content (slides, header, footer, etc) to slide to the right.
So far I have following working (it only moves words not images, or header):
<span style="font-size:20px;cursor:pointer" onclick="openNav()">☰ Site Menu</span>
<script>
function openNav() {
document.getElementById("mySidenav").style.width = "250px";
document.body.style.marginLeft = "250px";
}
</script>
I tried to adding lines such as:
document.lss-slide.background.marginLeft = "250px" or
.lss-slide.content.marginLeft = "250px" or
c5wrapper.marginLeft = "250px"
Without any success
Any input would be helpful. I apologize if this is a basic quesiton, I'm still learning CSS/Javascript etc.
Thanks,
Chris
I placed the above code for the side menu in the global "Sitewide Site Name" block and the menu behaves fine. However, when I can't get the "main" content (slides, header, footer, etc) to slide to the right.
So far I have following working (it only moves words not images, or header):
<span style="font-size:20px;cursor:pointer" onclick="openNav()">☰ Site Menu</span>
<script>
function openNav() {
document.getElementById("mySidenav").style.width = "250px";
document.body.style.marginLeft = "250px";
}
</script>
I tried to adding lines such as:
document.lss-slide.background.marginLeft = "250px" or
.lss-slide.content.marginLeft = "250px" or
c5wrapper.marginLeft = "250px"
Without any success
Any input would be helpful. I apologize if this is a basic quesiton, I'm still learning CSS/Javascript etc.
Thanks,
Chris
Type: | Pre-Sale |
---|---|
Status: | In Progress |
Hi Jordi,
Wow - thanks for such a fast response.
Quick follow-up question: Where would I put the classes you describe? I could not tell by looking at the inspect tool (still new at this). Should they go in the Custom CSS section?
When I place your c5wrapper classes in the “style” section of my sidebar menu I do not see the transition. When I put the classes in the javascript section, the menu link (in site name block) becomes unresponsive to mouse clicks.
If you have time, an incomplete version of my website is available at:
http://christopherrhodes.org/
Otherwise, I’ll keep experimenting with it.
Thanks for such a great theme!
Chris
Wow - thanks for such a fast response.
Quick follow-up question: Where would I put the classes you describe? I could not tell by looking at the inspect tool (still new at this). Should they go in the Custom CSS section?
When I place your c5wrapper classes in the “style” section of my sidebar menu I do not see the transition. When I put the classes in the javascript section, the menu link (in site name block) becomes unresponsive to mouse clicks.
If you have time, an incomplete version of my website is available at:
http://christopherrhodes.org/
Otherwise, I’ll keep experimenting with it.
Thanks for such a great theme!
Chris
Hi Chris,
I see you have added an HTML block to the Site Name area, so you could add the classes using that block.
You need to add the CSS definitions in the <style> section and also some javascript code to add and remove the classes in the <script> section.
The final code of the HTML block should look like this:
Hope this helps,
Jordi
I see you have added an HTML block to the Site Name area, so you could add the classes using that block.
You need to add the CSS definitions in the <style> section and also some javascript code to add and remove the classes in the <script> section.
The final code of the HTML block should look like this:
<style> body { font-family: "Lato", sans-serif; } .sidenav { height: 100%; width: 0; position: fixed; z-index: 1; top: 0; left: 0; background-color: #111; overflow-x: hidden; transition: 0.5s; padding-top: 60px;
Viewing 15 lines of 145 lines. View entire code block.
Hope this helps,
Jordi
Now I understand!
It works great - thanks
It works great - thanks
Generally, for this type of menu, you would change the CSS3 transform property:
transform: translate(250px, 0)
For instance, you could add a CSS class ("move-left") to the content when the sidebar is visible:
This is how the concrete5 dashboard works (to make sidebar menus slide in, the transform property is changed).
Here is an experiment I made for the 5.6 version of the theme with this type of menu:
http://longstoryshortparallax.15robots.com/offcanvas...
You can use the browser inspect tool to see wha'ts happening.
Let me know if you have any further questions (and feel free to post a link to your website if you want me to have a look)
Regards,
Jordi