- Cross-platform Desktop Application Development:Electron,Node,NW.js,and React
- Dmitry Sheiko
- 222字
- 2021-07-15 17:36:25
Styling a file list
The file list will be represented as a table, but we will build it out of an unordered list. The./index.html file contains the following code:
<main class="l-main__file-list file-list">
<nav>
<ul>
<li class="file-list__li file-list__head">
<span class="file-list__li__name">Name</span>
<span class="file-list__li__size">Size</span>
<span class="file-list__li__time">Modified</span>
</li>
<li class="file-list__li">
<span class="file-list__li__name">index.html</span>
<span class="file-list__li__size">1.71 KB</span>
<span class="file-list__li__time">3/3/2017, 15:44:19</span>
</li>
<li class="file-list__li">
<span class="file-list__li__name">package.json</span>
<span class="file-list__li__size">539 B</span>
<span class="file-list__li__time">3/3/2017, 17:53:19</span>
</li>
</ul>
</nav>
</main>
In fact, here Grid Layout (https://www.w3.org/TR/css3-grid-layout/) would probably suit better; however, at the time of writing, this CSS module was not yet available in NW.js. So, we go on again with Flexbox:
./assets/css/Component/file-list.css
.file-list {
background-color: var(--filelist-bg-color);
color: var(--filelist-fg-color);
cursor: pointer;
}
.file-list__li {
display: flex;
flex-flow: row nowrap;
}
.file-list__li:not(.file-list__head){
cursor: pointer;
}
.file-list__li:not(.file-list__head):hover {
color: var(--filelist-fg-hover-color);
}
.file-list__li > * {
flex: 1 1 auto;
padding: 0.8em 0.8em;
overflow: hidden;
}
.file-list__li__name {
white-space: nowrap;
text-overflow: ellipsis;
width: 50%;
}
.file-list__li__time {
width: 35%;
}
.file-list__li__size {
width: 15%;
}
I believe that everything is clear with the preceding code, except that you might not be familiar with the pseudo-class :not(). I want to change the color and mouse cursor on hover for all the file list items, except the table header. So, I achieve it with a selector that can be read like any .file-list__li that is not .file-list__head.
The following assignment goes to the definitions file:
./assets/css/Base/definitions.css
--filelist-fg-hover-color: #d64937;
As we run the application we can see the table with the file list:

- DBA攻堅(jiān)指南:左手Oracle,右手MySQL
- Java系統(tǒng)分析與架構(gòu)設(shè)計(jì)
- MySQL 8 DBA基礎(chǔ)教程
- 數(shù)據(jù)庫系統(tǒng)原理及MySQL應(yīng)用教程
- UML 基礎(chǔ)與 Rose 建模案例(第3版)
- Test-Driven Machine Learning
- Spring+Spring MVC+MyBatis從零開始學(xué)
- Qlik Sense? Cookbook
- Scratch從入門到精通
- Learning ECMAScript 6
- The Applied Data Science Workshop
- KnockoutJS Blueprints
- 米思齊實(shí)戰(zhàn)手冊(cè):Arduino圖形化編程指南
- Learning HTML5 by Creating Fun Games
- Abaqus GUI程序開發(fā)指南(Python語言)