JSFiddle - React, Tailwind, and code Playground
by mogu10
HTML
<div class="slide-wrap">
<div class="slide-box">
<a href="URL">
<img src="サムネイル画像">
<p>記事のタイトルがここに入ります</p>
</a>
</div>
</div>
CSS
.slide-wrap {
background-color: #ccc;
display: flex;
margin: 0 auto;
max-width: 1080px;
width: 100%;
}
.slide-box {
height: auto;
margin-right: 1%;
width: 24%;
}
/* サムネイルとタイトルのスタイル調整 */
.slide-box a {
background-color: #fff;
color: #222;
display: block;
text-decoration: none;
}
.slide-box img {
display: block;
height: auto;
width: 100%;
}
.slide-box p {
font-weight: bold;
padding: 10px;
}
@media screen and (max-width: 479px) {
/* スマホではスライダーで表示 */
.slide-wrap {
overflow-x: scroll;
-webkit-overflow-scrolling: touch;
overflow-scrolling: touch;
}
.slide-box {
flex: 0 0 70%;
}
}
JavaScript
methods: {
someMethod(){
setInterval(function () {
console.log('30秒毎に処理')
setTimeout(
function() {
console.log('5秒後に処理')
setTimeout(
function() {
console.log('4秒後に処理')
}.bind(this),
4000
);
}.bind(this),
5000
);
}.bind(this), 30000)
},