簡體   English   中英

React.js,語義UI反應,菜單>項目問題

[英]Reactjs, semantic ui react, menu>item problems

這是我在這里的第一個問題,我是React應用程序和語義ui的新手,如果我的問題有點兒不對,對不起。

所以我在導入菜單后使用語義ui react創建了一個菜單。 現在,我可以選擇在給定選項中為菜單選擇任何背景色。 但我想將其設置為自定義顏色。 那么,如何在替代樣式表中定位呢? 我嘗試了.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>

那么如何定位菜單背景顏色,以及與定位菜單>項目有什么不同呢? 多謝你們。

您可以使用

  • 一個className屬性(確保它覆蓋當前CSS,在需要時使用!important
  • 內聯樣式<Menu style={{ backgroundColor: 'red'}}>
  • 樣式化的組件

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM