- 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:

- INSTANT Mock Testing with PowerMock
- The Complete Rust Programming Reference Guide
- 程序員修煉之道:程序設計入門30講
- Leap Motion Development Essentials
- C語言程序設計基礎與實驗指導
- 數據結構與算法JavaScript描述
- Lua程序設計(第4版)
- Mastering AndEngine Game Development
- Getting Started with NativeScript
- ANSYS Fluent 二次開發指南
- C# and .NET Core Test Driven Development
- Oracle GoldenGate 12c Implementer's Guide
- CRYENGINE Game Development Blueprints
- Python青少年趣味編程
- Java7程序設計入門經典