官术网_书友最值得收藏!

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:

主站蜘蛛池模板: 德令哈市| 呼图壁县| 连云港市| 贵溪市| 京山县| 通州区| 黑龙江省| 晴隆县| 诸城市| 华亭县| 泰兴市| 丹江口市| 吴旗县| 双辽市| 浦江县| 绥德县| 新闻| 抚顺县| 通城县| 波密县| 保德县| 永泰县| 普宁市| 谢通门县| 盐津县| 邹平县| 揭东县| 全南县| 平安县| 洛隆县| 买车| 肇源县| 阿城市| 武义县| 武冈市| 辰溪县| 项城市| 蕉岭县| 牡丹江市| 奉新县| 济宁市|