I have creating a sidebar using bootstrap and react with collapse when click the button
here it is: https://splendorous-sfogliatella-457670.netlify.app/
If you go above link you can find the Left bar Red icon but when I click the button it collapse its okay but right panel width couldn't change as per proportion.
const [sidebar, setSidebar] = useState(true);
const showSidebar = () => setSidebar(!sidebar);
<div className="col col-2 col-lg-2 p-0" sidebar={sidebar} >
SideBar {It is in SideBar Component}
</div>
<div className="col col-10 col-lg-10 p-0" >
Main Content Panel {It is in Another Component}
</div>
I get the both component in Pages
<div className="row">
<Sidebar/>
<MainComponent/>
</div>
So How can I change the col width If Sidebar is collapsed
Related
black line above imageI am trying to create a product card using Tailwind CSS for styling. Whenever I get the image in the place that I want, there is a black line at the very top of the card/image. I have tried taking out all of the styles concerning my tag and it still seems to be there. Here is my code:
import React from 'react'
import coffeemerch from "../images/Coffee-Product photo.jpg";
export default function Products() {
return (
<div className="card w-96 bg-base-100 shadow-xl top-40 left-32">
<figure> <img className=" h-80 justify-center " src={coffeemerch} alt="coffee-product"></img></figure>
<div className="card-body">
<h2 className="card-title text-red-800">Medium Roast</h2>
</div>
</div>
);
}
I have a demo here
Its a super simple app with four buttons and a text area.
When you click a buttons it loads different text
The text is different lengths so the grey container gets taller and shorter
Is it possible to animate the grey box when the text gets taller and shorter
const [text, setText] = useState(textArr[3])
return (
<div>
<div className="nav">
<button onClick={() => setText(textArr[0])}>
One
</button>
<button onClick={() => setText(textArr[1])}>
Two
</button>
<button onClick={() => setText(textArr[2])}>
Three
</button>
<button onClick={() => setText(textArr[3])}>
Four
</button>
</div>
<div className="text">
{text}
</div>
</div>
);
I put a parent div with overflow: hidden applied to it then I used a useEffect to calculate the height of the text div when the text changes and then I set the height of the parent div to this height.
With transition on the parent div, it animates.
See demo here : https://stackblitz.com/edit/react-t7ctuf?file=src%2FApp.js
I have a header section in a website which consists of:
Logo
Login, Register buttons
Menu
Language picker
And I want to make them in a single row, but the problem is that they overlap each other when I am resizing the window, specifically the login button overlaps the logo and the language picker overlaps the main menu.
<div id="header-container" class="container">
<div id="header-container-nav" class="row align-items-center">
<div class="col-md-3">LOGO</div>
<div class="col-md-1">LOGIN BUTTONS</div>
<div class="col-md-5">MENU</div>
<div class="col-md-1">LANGUAGE</div>
</div>
</div>
Instead of using bootstrap here, I would use flex
I'd use this HTML
<div id="header-container-nav">
<div">LOGO</div>
<div>LOGIN BUTTONS</div>
<div>MENU</div>
<div>LANGUAGE</div>
</div>
and this CSS
#header-container-nav {
display: flex;
}
And now you can adjust the size of each item (check out this article http://javascriptkit.com/dhtmltutors/css-flexbox2.shtml)
I have looked everywhere on the docs, and nothing. Im looking for a similar navbar collapse function that's used in bootstrap with the hamburger(I can click on) to side and menu items inside of it. Please help.
Semantic UI looks good but can be a pain to use
This is a pretty good (and simple) implementation (credit: https://codepen.io/designosis/pen/LbMgya)
HTML
<div class="ui grid">
<div class="computer only row">
<div class="column">
<div class="ui menu">
<a class="item">Menu Item A</a>
<a class="item">Menu Item B</a>
<a class="item">Menu Item C</a>
<a class="item">Menu Item D</a>
</div>
</div>
</div>
<div class="tablet mobile only row">
<div class="column">
<div class="ui menu">
<a id="mobile_item" class="item"><i class="bars icon"></i></a>
</div>
</div>
</div>
</div>
<div class="ui pushable segment">
<div class="ui sidebar vertical menu">
<a class="item">Menu Item A</a>
<a class="item">Menu Item B</a>
<a class="item">Menu Item C</a>
<a class="item">Menu Item D</a>
</div>
<div class="pusher">
<div id="content" class="ui segment">
Content here
</div>
</div>
</div>
CSS
#content {
min-height: 100px;
}
.ui.grid{
padding: 0 !important;
}
.pushable.segment{
margin: 0 !important;
}
JavaScript
$('.ui.sidebar').sidebar({
context: $('.ui.pushable.segment'),
transition: 'overlay'
}).sidebar('attach events', '#mobile_item');
Here is a collapsable NavMenu component I've made using the Responsive component available in Semantic-UI-React:
import React, { useState } from 'react';
import { Menu, Responsive, Dropdown, DropdownMenu } from 'semantic-ui-react';
import { withRouter } from 'react-router-dom';
import LogoutModal from './LogoutModal';
function NavMenu(props) {
const [activeItem, setActiveItem] = useState('Laptop Item')
const [showModal, setShowModal] = useState(false)
return (
<div>
<Menu pointing secondary>
<Responsive as={Menu.Item} minWidth={790}
name='Laptop Item'
active={activeItem === 'Laptop Item'}
onClick={() => setActiveItem('Test Item')}
/>
<Responsive as={Menu.Item} minWidth={790}
name='Laptop Item 2'
active={activeItem === 'Laptop Item 2'}
onClick={() => setActiveItem('Test Item 2')}
/>
<Responsive as={Menu.Item} minWidth={790}
name='Laptop Item 3'
active={activeItem === 'Laptop Item 3'}
onClick={() => setActiveItem('Test Item 3')}
/>
<Menu.Menu position = 'right'>
<Responsive as ={Menu.Item} minWidth={790}
name = "Sign Out"
onClick={() => setShowModal(true)}
/>
</Menu.Menu>
<Responsive as ={Menu.Menu} maxWidth={789} position='right'>
<Dropdown
item
icon ='bars'
>
<Dropdown.Menu>
<Dropdown.Item text='Mobile/Tablet Item 1'/>
<Dropdown.Item text='Mobile/Tablet Item 2'/>
<Dropdown.Item text='Mobile/Tablet Item 3'/>
<Dropdown.Item text='Sign Out'/>
</Dropdown.Menu>
</Dropdown>
</Responsive>
</Menu>
</div>
)
}
export default withRouter(NavMenu);
I'm going for a traditional looking navigation bar with links on the left side and a Logout button on the right side. Although the width in pixels of an iPad (as shown in Chrome dev tools) is 768px, for some reason the breakpoint is 790px for me (appreciate if someone can tell me why this is). That is why min width for 'Laptop Items' is 790 and maxWidth for 'Mobile/Tablet Items' is 789.
I did not find the responsive component in the Semantic-UI docs. It is listed under "Addons" in Semantic-UI-React.
If you're not using React an alternative is to implement the side bar for mobile users.
if you are counting towards the semantics the most correct is you use the tags list as navbar and hide it or not with javascript.
Really html semantics is very bad, very complex code to do something simple
I'm trying to use material2 sidenav component. I want it to be separate from content. Just a full-height sidebar that slides there and back - without any sidenav-layout as it creates some unwanted things in my app layout.
What I want looks really close to https://inbox.google.com/u/0/?pli=1 sidenav.
What I currently have is:
If you want to separate side bar and main content, Use the bootstrap column classes to achieve as below,
<md-sidenav-container class="container-fluid">
<div class="col-md-1">
<button md-button (click)="sidenav.open()">
<i class="fa fa-list"></i>
</button>
</div>
<div class="col-md-11">
Main content goes here
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
</div>
<md-sidenav #sidenav class="example-sidenav">
Manu bar
</md-sidenav>
</md-sidenav-container>
Note:Break tags are added to increase the height of the content.
LIVE DEMO