3 回答

TA貢獻1831條經驗 獲得超9個贊
沒有理由將該標題放入 material-uiList元素中并強制其進入邊框。只需將 包裝List在一個組件中,該組件在列表之前呈現標題:
const ListWithHeading = ({heading, classes, children, ...props}) => (
<div className="list-container">
<Typography className={classes.fieldLabel}>{heading}</Typography>
<List classes={classes} {...props}>{children}</List>
</div>
);
您可以給包含headinga 類的元素設置樣式,例如給它背景顏色并使其全寬。
像這樣渲染它:
<ListWithHeading heading="Attach PDF">
{/* list items here */}
</ListWithHeading>

TA貢獻1725條經驗 獲得超8個贊
而不是試圖彎曲空間和時間來向上移動文本 - 只需刪除頂部邊框 - 并使文本的高度和背景與內部布局相匹配。
我已經使用類躲過了你的元素 - 它很簡單。并且沒有空間或時間的彎曲:)
.root {
width: 100%;
max-width: 360px;
border: 3px solid #388FCE;
margin-left: 3%;
max-height: 200px;
overflow: auto;
border-top: none;
display: block;
}
.fieldLabel {
height: 40px;
line-height: 40px;
background: #388FCE;
font-size: 1rem;
text-transform: uppercase;
letter-spacing: 3px;
color: red;
font-weight: bold;
display: block;
padding-left: 10px
}
<List class="root">
<Typography class="fieldLabel">
Attach PDF
</Typography>
{/***SOME CODE**/}
</List>

TA貢獻1856條經驗 獲得超5個贊
我會建議你使用 ListSubheader?
? <List?
? ? ? className={classes.root}?
? ? ? subheader={
? ? ? ? <ListSubheader className={classes.subHeader} component="div">
? ? ? ? ? Attach PDF
? ? ? ? </ListSubheader>
? ? ? }>
? ? ? ? ? {/*** Your List Items**/}
? </List>
并為其添加樣式。例如:
subHeader: {
? background: '#388FCE',
? // other required styles
}
添加回答
舉報