Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I want to put a logo on the left side of the Toolbar in React (Material-UI Apppbar), but I don't get why it doesn't work. The logo is not showing at all.

import logo from '../../assets/companylogo.png';


const useStyles = makeStyles((theme) => ({
    ...

    logo: {
      width: '10%',
    },

    ...
}));

<AppBar position='sticky'>
    <Toolbar className={classes.toolbar} variant='dense'>
        <img scr={logo} className={classes.logo}/>
        <div className={classes.search}>
            ...
        </div>
        <div className={classes.grow} />
        <div className={classes.sectionDesktop}>
            ...
        </div>
        <div className={classes.sectionMobile}>
            ...
        </div>
    </Toolbar>
</AppBar>

When <img/> is included I can see the width changes on the left depending on what the width of the logo is set to. enter image description here

Here it is without the <img/> enter image description here

I tried different images both .png and other formats, but id doesn't solve anything. I made sure the path to images is correct and also tried to wrap the <img/> with <div></div>, but nothing solved it. I thought it might be a z-index issue and the image is simply hiding behind the Toolbar, but that doesn't make sense to me and after playing a bit with zIndex value for image it didn't solve it either. I'm out of ideas here.

Any idea what am I doing wrong here?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
176 views
Welcome To Ask or Share your Answers For Others

1 Answer

等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...