div中的内容超出宽度后,怎么设置出滚动条,就是可以左右滑动
- User
div中的内容超出宽度后,怎么设置出滚动条,就是可以左右滑动
- Assistant
可以设置 div 的样式为:
div { overflow-x: auto; white-space: nowrap; }其中
overflow-x: auto表示当内容超出 div 的宽度时,自动出现水平滚动条,white-space: nowrap则是防止内容换行,保持在同一行中。这样就可以左右滑动 div 内的内容了。 - User
jsx中这段代码怎么才能内容超过宽度后自动出现滚动条,能左右滚动<div style={{display: 'flex', alignItems: 'center',overflow:"scroll",width: "100%"}}>
{Array.isArray(record.mainPeople) && record.mainPeople.map((itemPerson: string, index: number) => ( <> <img src={'https://serverless.sankuai.com/dx-avatar/?type=img&mis=' + itemPerson} style={{ width:'30px', height:'30px', borderRadius:'15px', marginRight: 5 }} // onClick={()=>{ window.open('https://x.sankuai.com/bridge/chat?uid=1799802462')}} /> <span style={{ marginRight:5 }}>{itemPerson}</span> </> ))} </div> - Assistant
你可以将
overflow:"scroll"设置为overflowX: "auto",然后在外层套一个 div 作为滚动区域容器。<div style={{ display: 'flex', alignItems: 'center', overflowX: "auto" }}> <div style={{ width: "100%", whiteSpace: "nowrap" }}> {Array.isArray(record.mainPeople) && record.mainPeople.map((itemPerson: string, index: number) => ( <> <img src={'https://serverless.sankuai.com/dx-avatar/?type=img&mis=' + itemPerson} style={{ width:'30px', height:'30px', borderRadius:'15px', marginRight: 5 }} // onClick={()=>{ window.open('https://x.sankuai.com/bridge/chat?uid=1799802462')}} /> <span style={{ marginRight:5 }}>{itemPerson}</span> </> ))} </div> </div>这里的样式
whiteSpace: "nowrap"会禁止换行,使得内容在同一行中显示。而外层的 div 设置了overflowX: "auto",当内容超出它的宽度时,会出现水平滚动条以方便左右滑动内容。 - User
localdate获取毫秒数
- Assistant
你可以使用
java.time.LocalDate类的atStartOfDay()方法转换为java.time.LocalDateTime,再使用java.time.LocalDateTime类的atZone(ZoneId.of("时区"))方法转换为指定时区的java.time.ZonedDateTime,并使用其toInstant()方法得到java.time.Instant类型的时间戳,再使用其toEpochMilli()方法获取毫秒数。示例代码如下所示:
LocalDate localDate = LocalDate.of(2022, 1, 1); long millis = localDate.atStartOfDay() .atZone(ZoneId.of("Asia/Shanghai")) .toInstant() .toEpochMilli(); System.out.println(millis); // 输出:1640966400000其中,例如
"Asia/Shanghai"表示中国上海的时区,你可以根据实际需求替换为其他时区的标识符。
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.