- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我发现在滚动时更改 material-ui Appbar 组件颜色非常困难。我一直想知道是否有这样的功能。我也不知道“useScrollTrigger”是否可以在这里工作。但是如果可以的话,请帮帮我。
这是我的代码:
import React, {Component} from 'react';
import '../css/Home.css'
import Typography from '@material-ui/core/Typography'
import { withStyles, createStyles } from '@material-ui/core'
import AppBar from '@material-ui/core/AppBar';
import Toolbar from '@material-ui/core/Toolbar';
import Avatar from '@material-ui/core/Avatar';
import Grid from '@material-ui/core/Grid';
import Button from '@material-ui/core/Button';
// import Divider from '@material-ui/core/Divider'
import Slide from '../components/Slider'
import {Link} from 'react-router-dom';
const styles = theme => createStyles({
appbar: {
background: 'transparent',
boxShadow: 'none',
transition: '.5s'
},
avatar: {
width: '70px',
height: '70px',
marginLeft: 100
},
fragment: {
position: 'absolute',
right: '10em'
},
links: {
marginLeft: '40px',
fontFamily: 'Trebuchet MS',
fontWeight: 'bold',
padding: '10px',
borderRadius: '5px',
transition: '.8s'
},
mainGrid: {
marginTop: '150px',
fontFamily: 'Trebuchet MS'
},
grid: {
display: 'flex',
alignItems: 'center',
justifyContent: 'center'
},
button: {
backgroundImage: 'linear-gradient(to right, rgb(26, 131, 252), rgb(250, 29, 250))',
color: 'white',
transition: '.5s'
},
img: {
width: '90%',
height: '90%'
},
section: {
marginTop: '150px',
padding: '20px',
borderRadius: '40px'
},
showcase: {
[theme.breakpoints.down('sm')]: {
width: '100%',
textAlign: 'center'
},
margin: '40px auto',
marginTop: '40px',
width: '50%',
},
slider: {
backgroundColor: 'rgba(0, 0, 0, 0.671)',
padding: '12px 25px',
borderRadius: '20px'
}
})
class Home extends Component {
render(){
const {classes} = this.props;
return(
<div >
<AppBar id='header' position='fixed' className={classes.appbar} >
<Toolbar>
<Avatar
src='logo.png'
variant='square'
className={classes.avatar}
/>
<div className={classes.fragment} >
<Typography color='primary' className={classes.links} variant='inherit' component={Link} to='about' id='links' >About me</Typography>
<Typography color='primary' className={classes.links} variant='inherit' component={Link} to='/gallery' id='links' >Gallery</Typography>
<Typography color='primary' className={classes.links} variant='inherit' component={Link} to='/contact' id='links' >Contact me</Typography>
<Typography color='primary' className={classes.links} variant='inherit' component={Link} to='/hire' id='links' >Hire me</Typography>
</div>
</Toolbar>
</AppBar>
<Grid className={classes.mainGrid} container >
<Grid item className={classes.grid} xs={12} sm={12} md={6} lg={6} >
<div>
<Typography style={{letterSpacing: '1px'}} variant='body2' color='primary' >HEY THERE !</Typography><br />
<Typography style={{fontWeight: 'bold', fontSize: '30px', letterSpacing: '1px'}} variant='h5' color='primary' >I AM NATHAN BRAIN</Typography><br />
<Typography style={{ fontWeight: 500, fontSize: '15px', letterSpacing: '1px'}} variant='h5' color='primary' >CREATIVE WEB DESIGNER AND DEVELOPER</Typography><br />
<br />
<Button id='button' className={classes.button} >
SEE MY WORKS
</Button>
</div>
</Grid>
<Grid item xs={12} sm={12} md={6} lg={6} >
<img className={classes.img} src='nathan.png' alt='nathan' />
</Grid>
</Grid>
<section className={classes.section} >
<div className={classes.showcase} >
<Typography variant='h4' color='primary' style={{fontWeight: 'bold', marginBottom: '40px', fontFamily: 'Trebuchet MS'}} >SHOWCASE</Typography>
<div className={classes.slider}>
<Slide />
</div>
</div>
</section>
</div>
)
}
}
export default withStyles(styles)(Home);
这都是基本的。 AppBar 现在是透明的,但我需要它在滚动时更改颜色。我没有尝试做任何事情,因为我一直在搜索文档,但找不到类似的东西。如果可以的话,请帮帮我。提前致谢,
最佳答案
I also don't know if the 'useScrollTrigger' can work here
MUI 的 useScrollTrigger() 可以让您在滚动时更改许多 AppBar 的设置。这包括在滚动时更改 AppBar 颜色。
您可以查看我的codesandbox了解如何使用 MUI 的 useScrollTrigger() 来实现这一点。
关于node.js - Material-ui AppBar。滚动时更改颜色。 react ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62058481/
在 app_bar.dart 文件中提到,海拔控制应用栏下方阴影的大小,并且默认情况下,如果没有内容在 AppBar 下滚动,则不会绘制阴影。 这是我的代码: Scaffold( appBar:
我正在创建一个 GlobalPage/FrameHoster,其中将包含我的 AppBar,然后创建一个将托管我的所有应用程序页面的 Frame 控件。除了一些页面导航控件被应用栏隐藏之外,这一切都很
我正在尝试实现 flutter_tagging里面AppBar .我设法添加了标签 TextField里面AppBar并调整 AppBar使用 PreferredSize使用以下代码的小部件: ret
我的 AppBar 在屏幕上的图像后面或者我看不到它,有什么建议可以在顶部显示我的 AppBar 和 buttomNavigator 并且是半透明的吗? Widget build(BuildConte
我的应用栏上有两个图标,点击保存保存图标消失,批准图标会弹出它工作正常,但根据下图在大屏幕上通过应用栏图标剪切。这是我的代码 appBar: PreferredSize( preferre
我想在容器上的 DoubleTap 上动态隐藏和显示 App Bar,并在隐藏时使用一些动画,但此链接的解决方案不适用于我的项目:Flutter - How can I dynamically sho
自定义应用栏的屏幕截图: 我想制作一个像照片一样的自定义应用栏任何人都可以帮助我创建这个我已经搜索了很多但没有找到任何地方 最佳答案 我不认为它是一个圆形的appBar,而是它下面的一个圆形的容器。
嘿,我正在创建底部应用栏并向其添加 3,应用栏按钮,如下所示。一个使用内置图标,另外两个使用位图图标 带有位图图标的 AppBarButton 在设计 View 中正确显示,即包含在
自定义应用栏的屏幕截图: 我想制作一个像照片一样的自定义应用栏任何人都可以帮助我创建这个我已经搜索了很多但没有找到任何地方 最佳答案 我不认为它是一个圆形的appBar,而是它下面的一个圆形的容器。
嘿,我正在创建底部应用栏并向其添加 3,应用栏按钮,如下所示。一个使用内置图标,另外两个使用位图图标 带有位图图标的 AppBarButton 在设计 View 中正确显示,即包含在
代码:
我创建了一个 AppBar。 AppBar 始终保持在顶部,当它失去焦点时,返回到 AppBar 需要点击两次而不是一次。我相信第一次点击会激活表单,然后第二次点击我会收到鼠标点击事件(如预期的那样)
我制作了一个简单的 appBar,在屏幕顶部只有一个标签可以缩小桌面,但我无法让它显示为我的第二台显示器。我一直在四处寻找,但我发现的一切都是针对 WPF 的。这些很可能是我犯错的地方,但如果您需要查
当你想让你的应用扩展到全屏时(包括状态栏和应用栏),你必须这样做: var applicationView = Windows.UI.ViewManagement.ApplicationView.Ge
我写了一个应用程序桌面工具栏(又名 AppBar),它工作得很好,除了如果我终止进程,AppBar 代码永远没有机会通过发送 ABM_REMOVE 来清理。问题是这基本上搞砸了用户的桌面。 AppBa
我开始使用 React/Material-UI,也是 CSS 等的新手...我有一个带有 APPBar 的简单页面布局。不幸的是,此 AppBar 与本应位于其下方的元素重叠。 我找到了这个答案: A
我正在开发的 Windows 应用商店应用的主页上有两个 AppBar。一个在顶部用于导航,另一个在下方用于命令。 显然,我希望 AppBars 在单击新命令按钮后关闭。下面的代码可以工作,但看起来很
我的布局中有一个 AppBar 和一个水平线性布局(其中包括一个编辑文本和两个图像按钮)和其他内容。当用户向下滚动时,我想要 AppBar(实际上,Toolbar 隐藏。这是我尝试过的,appbar
我有一个应用栏,我想在其中显示标题,然后在它旁边有一个凸起的按钮,该按钮会展开以填充剩余的水平空间。我试过这个的变体: AppBar( title: Row( children: [
我正在尝试为我的所有屏幕使用相同的 Appbar,但我不想多次添加相同的代码,因此我考虑创建具有默认 Appbar 的类 MyAppbar,以便我可以使用它在我的屏幕上没有重复相同的代码,但我不知道我
我是一名优秀的程序员,十分优秀!