Reactjs,语义ui反应,菜单>项目问题

问题描述 投票:0回答:1

这是我在这里的第一个问题,我是React应用程序的初学者和语义ui的反应,很抱歉,如果我的问题有点小说。

所以我在导入后使用语义ui做出了反应。现在,我可以选择在给定选项中为菜单选择任何背景颜色。但我想将其设置为自定义颜色。那么我如何在覆盖样式表中定位它?我试过.ui.menu但失败了。这是代码的起始部分:

import React, { Component, createRef } from 'react'
import { Input, Menu, Image, Grid, Sticky } from 'semantic-ui-react'
import styled from 'styled-components'
import Link from 'next/link';
import { relative } from 'path';

export default class Navbar extends Component {
    constructor(props) {
        super(props);
    }
    state = { activeItem: this.props.currentPage }
    contextRef = createRef()
    render() {
        const { activeItem } = this.state
        return (
            <div >
                <Menu size="massive" className="size" pointing stackable>
                    <Image style={{ 'font-size': 50 }} avatar src='http://www.transitionsta.org/wp-content/uploads/2016/12/twitter-black-round-icon.png' className='logo' />
                        <Link href='/home'>
                            <Wrap>
                               <Menu.Item
                                  name='HOME'
                                  active={activeItem === 'home'}
                                  position='right'
                                   />
                             </Wrap>
                            </Link>
                            <Link href="/contact">
                              <Wrap>
                                  <Menu.Item
                                     name='CONTACT US'
                                     active={activeItem === 'contact us'}
                                     position='right'
                                    />
                                </Wrap>
                            </Link>
                            <Link href='/aboutProfile'>
                             <Wrap>
                              <Menu.Item
                                 name='ABOUT US'
                                 active={activeItem === 'about us'}
                                 position='right'
                                 />
                                </Wrap>
                            </Link>
                </Menu>

那么如何定位菜单背景颜色以及它与目标菜单>项目的确切方式有何不同?多谢你们。

css reactjs semantic-ui-react
1个回答
0
投票

您可以使用

  • className属性(确保它覆盖当前的CSS,在需要时使用!important
  • 内联风格<Menu style={{ backgroundColor: 'red'}}>
  • Styled Components
© www.soinside.com 2019 - 2024. All rights reserved.