我正在尝试从material UI创建一个水平菜单组件,但似乎无法做到,因为所有列表项都包装在一个<div>中
docs将显示垂直菜单列表
有效的方法是删除跨度内的所有外部divs,并删除应用于跨度的display: block样式。
<div style="padding: 8px 0px;">
<div>
<span tabindex="0" type="button" style="border: 10px; box-sizing: border-box; display: block; font-family: Roboto, sans-serif; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); cursor: pointer; text-decoration: none; margin: 0px; padding: 0px; outline: none; font-size: 16px; font-weight: inherit; transform: translate(0px, 0px); color: rgba(0, 0, 0, 0.870588); line-height: 16px; position: relative; transition: all 450ms cubic-bezier(0.23, 1, 0.32, 1) 0ms; background: none;">
<div>
<div style="margin-left: 0px; padding: 16px; position: relative;">
<div>Inbox</div>
</div>
</div>
</span>
</div>
<div>
<span tabindex="0" type="button" style="border: 10px; box-sizing: border-box; display: block; font-family: Roboto, sans-serif; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); cursor: pointer; text-decoration: none; margin: 0px; padding: 0px; outline: none; font-size: 16px; font-weight: inherit; transform: translate(0px, 0px); color: rgba(0, 0, 0, 0.870588); line-height: 16px; position: relative; transition: all 450ms cubic-bezier(0.23, 1, 0.32, 1) 0ms; background: none;">
<div>
<div style="margin-left: 0px; padding: 16px; position: relative;">
<div>Starred</div>
</div>
</div>
</span>
</div>
<div>
<span tabindex="0" type="button" style="border: 10px; box-sizing: border-box; display: block; font-family: Roboto, sans-serif; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); cursor: pointer; text-decoration: none; margin: 0px; padding: 0px; outline: none; font-size: 16px; font-weight: inherit; transform: translate(0px, 0px); color: rgba(0, 0, 0, 0.870588); line-height: 16px; position: relative; transition: all 450ms cubic-bezier(0.23, 1, 0.32, 1) 0ms; background: none;">
<div>
<div style="margin-left: 0px; padding: 16px; position: relative;">
<div>Sent mail</div>
</div>
</div>
</span>
</div>
<div>
<span tabindex="0" type="button" style="border: 10px; box-sizing: border-box; display: block; font-family: Roboto, sans-serif; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); cursor: pointer; text-decoration: none; margin: 0px; padding: 0px; outline: none; font-size: 16px; font-weight: inherit; transform: translate(0px, 0px); color: rgba(0, 0, 0, 0.870588); line-height: 16px; position: relative; transition: all 450ms cubic-bezier(0.23, 1, 0.32, 1) 0ms; background: none;">
<div>
<div style="margin-left: 0px; padding: 16px; position: relative;">
<div>Drafts</div>
</div>
</div>
</span>
</div>
<div>
<span tabindex="0" type="button" style="border: 10px; box-sizing: border-box; display: block; font-family: Roboto, sans-serif; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); cursor: pointer; text-decoration: none; margin: 0px; padding: 0px; outline: none; font-size: 16px; font-weight: inherit; transform: translate(0px, 0px); color: rgba(0, 0, 0, 0.870588); line-height: 16px; position: relative; transition: all 450ms cubic-bezier(0.23, 1, 0.32, 1) 0ms; background: none;">
<div>
<div style="margin-left: 0px; padding: 16px; position: relative;">
<div>Inbox</div>
</div>
</div>
</span>
</div>
</div>发布于 2016-11-18 07:43:52
在菜单上用“className : inline-block”设置直接DIV子对象样式的CSS
工作jsFiddle:https://jsfiddle.net/d980vcon/2/
在CSS中:
.horiz-menu > div {
display: inline-block;
}在JSX中:
class Example extends React.Component {
render() {
return (
<Menu className="horiz-menu">
<MenuItem primaryText="Home"/>
<MenuItem primaryText="Test Menu 1" />
<MenuItem primaryText="Test Menu 2" />
<MenuItem primaryText="About" />
</Menu>
);
}
}发布于 2018-04-26 23:57:34
您可以使用flex作为您的css的一部分,在您的菜单中,您可以使用属性className="myStyle"进行样式设置,如下所示:
.myStyle {
display: 'flex',
flexWrap: 'wrap',
justifyContent: 'space-around',
overflow: 'hidden'
}作为css的一部分。
https://stackoverflow.com/questions/40666857
复制相似问题