<div id="app">
<ul>
<li v-for="article in articles">
<h2><a :href="article.link">{{ article.title }}</a></h2>
<div class="summary">{{ article.summary | readMore(100, '...') }}</div>
<div class="action"><a :href="article.link">阅读更多</a></div>
</li>
</ul>
</div>
@import url(https://fonts.googleapis.com/css?family=Montserrat);
body {
background: #988185;
background-image: linear-gradient(40deg, rgba(70, 57, 60, 0.05), rgba(128, 0, 21, 0.05)), linear-gradient(135deg, #796366 0%, #796366 10%, #8c7377 11%, #8c7377 40%, #a38f92 41%, #a38f92 50%, #796366 51%, #796366 60%, #8c7377 61%, #8c7377 90%, #a38f92 91%);
background-size: 7px 7px, 4px 4px;
display: flex;
justify-content: center;
align-items: center;
font-family: montserrat;
}
html, body {
width: 100vw;
height: 100vh;
}
#app {
background: white;
border: 0 none;
border-radius: 3px;
box-shadow: 0 0 15px 1px rgba(0, 0, 0, 0.4);
padding: 20px 30px;
box-sizing: border-box;
text-align: center;
max-width: 90vw;
margin: 20px;
text-align: left;
}
ul {
margin: 0;
padding: 0;
list-style: none outside none;
li:not(:last-child) {
border-bottom: 1px solid #d3d7d9;
padding-bottom: 25px;
margin-bottom: 25px;
}
}
h2 a {
font-size: 24px;
color: #29B4F0;
text-decoration: none;
transition: color 0.3s ease;
&:hover {
color: #0d8abf;
}
}
.summary {
font-size: 16px;
line-height: 30px;
margin-bottom: 25px;
}
.action {
text-align: right;
a {
background-color: #008fb5;
color: #fff;
padding: 5px 10px;
line-height: 18px;
border-radius: 3px;
transition: all 0.28s ease-in;
text-decoration: none;
&:hover {
background-color: #00b7e9;
}
}
}
View Compiled
// 声明一个全局的过滤器readMore
// 这个过滤器传了三个参数:text, length, suffix
Vue.filter('readMore', function (text, length, suffix) {
return text.substring(0, length) + suffix
})
let app = new Vue({
el: '#app',
data () {
return {
articles: [
{
title: 'CSS :focus-within',
summary: 'CSS的世界真是一个神奇的世界。可能众多前端开发者听说过:focus并未听说过:focus-within。那么:focus-within是什么鬼。这篇文章,我们就说说:focus-within这个东东。在CSS中:focus-within是一个伪类,现在已经被列入到CSS选择器中(CSS Level 4 selector)。他就像你知道的:focus或者:hover。:focus-within能非常方便处理获取焦点状态。当元素本身或其后代元素获得焦点时,:focus-within伪类的元素就会有效。',
link: '//www.w3cplus.com/css/focus-within.html'
},
{
title: '如何改变表单控件光标颜色',
summary: '表单大家应该不陌生,当然了,今天并不是来聊怎么做表单或者处理表单的样式网格。而是来聊聊怎么改变表单控件中光标的颜色。不知道在大家心中,表单控件的光标颜色是根据color属性来控制的。那么如果需要用CSS来改变表单控件,比如说input或者textarea元素的光标颜色,应该怎么处理呢?',
link: '//www.w3cplus.com/css/caret-color.html'
}
]
}
}
})
View Compiled
This Pen doesn't use any external CSS resources.