gpt4 book ai didi

css - 如何在 React.js 中使用 Reactstrap 将 Navbar Collapse 转换为移动 View 中的侧边栏?

转载 作者:行者123 更新时间:2023-11-28 01:24:15 34 4
gpt4 key购买 nike

引用下面评论中的图片链接,你知道如何在移动 View 中实现将导航栏折叠成侧边栏的效果吗?如何在不影响和移动 Logo 和按钮的情况下实现它?

//[Home Navbar Desktop View]: /image/THf6k.jpg 
//[Home Navbar Mobile View]: /image/CiJOc.png
//[Home Navbar/Sidebar Extend Mobile View]: /image/HhJxQ.png

import React, { Component } from 'react';
import { Switch, Route } from 'react-router-dom';
import Home from "./components/home/home";
import About from "./components/about/about";
import Portfolio from "./components/portfolio/portfolio";
import Services from "./components/services/services";
import { Collapse, Navbar, NavbarToggler, NavbarBrand, Nav, NavItem, NavLink, Button } from 'reactstrap';
import './App.css';
import 'tachyons';

class App extends Component {
constructor(props) {
super(props);

this.toggle = this.toggle.bind(this);
this.state = {
isOpen: false
};
}
toggle() {
this.setState({
isOpen: !this.state.isOpen
});
}
render() {
return (
<div className='App'>
<Navbar className='sticky-top' color="light" light expand="md">
<NavbarBrand href="/"><b className='logo'>Amecle</b></NavbarBrand>
<NavbarToggler className="order-first" onClick={this.toggle} />
<Collapse isOpen={this.state.isOpen} navbar>
<Nav className="ml-auto" navbar>
<NavItem>
<NavLink href="/about">About</NavLink>
</NavItem>
<NavItem>
<NavLink href="/services">Services</NavLink>
</NavItem>
<NavItem>
<NavLink href="/portfolio">Portfolio</NavLink>
</NavItem>
</Nav>
</Collapse>
<Button className="still_on_view" outline color="primary">Request a quote</Button>{' '}
</Navbar>

最佳答案

这个答案对我有用。

<Navbar className='sticky-top' color="light" light expand="md">更改 expand="md"expand="lg" (这表示最大 1024 像素(ipad 大小)的媒体将折叠。

关于css - 如何在 React.js 中使用 Reactstrap 将 Navbar Collapse 转换为移动 View 中的侧边栏?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51334747/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com