Code Slider Post Làm Trang Chủ



Demo

Đầu tiên chèn đoạn css dưới:

<link href="css/style.css" rel="stylesheet" type="text/css"></link>
<link href="https://fonts.googleapis.com/css?family=Slabo+27px" rel="stylesheet"></link>
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"></link>
<style>
body,html {
width: 100%;
height: 100%;
padding: 0;
margin: 0;
display: block;
position: relative;
overflow: hidden;
font-family: 'Slabo 27px', serif;
font-size: 16px;
}

h1,h2,h3,h4,h5,h6 {
padding: 0;
margin: 0;
}
ul,li,p {
margin: 0;
padding: 0;
}
a {
text-decoration: none;
}
.wrapper {
height: 100%;
width: 100%;
display: block;
overflow: hidden;
}
.wrapper .container {
height: 100%;
width: 100%;
display: block;
overflow: hidden;
}

.slideshow {
height: 100%;
width: 100%;
display: block;
overflow: hidden;
}
.slideshow .slideshow-left {
width: 40%;
float: left;
position: relative;
height: 100%;
}
.slideshow .slideshow-left .Lslide {
height: 100%;
display: block;
overflow: hidden;
position: absolute;
bottom: 0px;
top: 0;
left: 0;
right: 0;
}
.slideshow .Lslide-content {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
-moz-transform: translate(-50%, -50%);
-webkit-transform: translate(-50%, -50%);
}
.slideshow .Lslide-content h2 {
color: #fff;
font-weight: 600;
font-size: 60px;
line-height: 0.8;
}
.slideshow .Lslide-content p {
color: #fff;
padding: 2.5em 0em;
}
.slideshow .Lslide-content .button {
background-color: #fff;
display: inline-block;
border-radius: 25px;
position: relative;
}
.slideshow .Lslide-content .button i {
float: right;
position: absolute;
top: 50%;
right: 2.5em;
color: #000;
font-size: 9px;
transform: translateY(-50%);
-ms-transform: translateY(-50%);
-moz-transform: translateY(-50%);
-webkit-transform: translateY(-50%);
transition: all 0.3s;
}
.slideshow .Lslide-content .button:hover i {
right: 1.7em;
}
.slideshow .Lslide-content .button p {
margin: 0;
padding: 0;
color: #000;
text-align: left;
padding: 0.8em 8em 0.8em 1.5em;
font-size: 12px;
font-weight: 600;
}
.slideshow .slideshow-right {
width: 60%;
float: left;
position: relative;
height: 100%;
}
.slideshow .slideshow-right .Rslide {
height: 100%;
display: block;
overflow: hidden;
position: absolute;
bottom: 0px;
top: 0;
left: 0;
right: 0;
}
.slideshow .slideshow-right .Rslide img {
min-width: 100%;
}
.control {
position: absolute;
left: 40%;
top: 50%;
transform: translateY(-50%);
-ms-transform: translateY(-50%);
-moz-transform: translateY(-50%);
-webkit-transform: translateY(-50%);
}
.control i {
left: 0;
right: 0;
top: 50%;
transform: translateY(-50%);
-ms-transform: translateY(-50%);
-moz-transform: translateY(-50%);
-webkit-transform: translateY(-50%);
text-align: center;
position: absolute;
color: #aaaaaa;
transition: all 0.3s;
-ms-transition: all 0.3s;
-moz-transition: all 0.3s;
-webkit-transition: all 0.3s;
}
.control .control-top {
width: 45px;
height: 50px;
background-color: #fff;
z-index: 5;
position: relative;
border-radius: 0px 4px 4px 0px;
cursor: pointer;
}
.control .control-top:hover i {
color: #333333;
}
.control .control-bottom {
width: 45px;
height: 50px;
background-color: #fff;
z-index: 5;
position: relative;
border-radius: 4px 0px 0px 4px;
left: -45px;
cursor: pointer;
}
.control .control-bottom:hover i {
color: #333333;
}
</style>

Tiếp theo là đoạn code hiển thị:
 <div class="wrapper">
           <div class="container">

               <div class="slideshow">

                    <div class="slideshow-left">

                        <div class="Lslide">
                            <div class="Lslide-content">
                                <h2>Probably not</h2>
                                <p>Be a part of our creation</p>

                                <div class="button">
                                    <a href="#">
                                        <p>More</p>
                                        <i class="fa fa-chevron-right" aria-hidden="true"></i>
                                    </a>
                                </div>
                            </div>
                        </div>
                        <div class="Lslide">
                            <div class="Lslide-content">
                                <h2>But not today</h2>
                                <p>Be a part of our creation</p>

                                <div class="button">
                                    <a href="#">
                                        <p>More</p>
                                        <i class="fa fa-chevron-right" aria-hidden="true"></i>
                                    </a>
                                </div>
                            </div>
                        </div>
                        <div class="Lslide">
                            <div class="Lslide-content">
                                <h2>Probably not</h2>
                                <p>Be a part of our creation</p>

                                <div class="button">
                                    <a href="#">
                                        <p>More</p>
                                        <i class="fa fa-chevron-right" aria-hidden="true"></i>
                                    </a>
                                </div>
                            </div>
                        </div>   

                    </div>

                    <div class="slideshow-right">

                        <div class="Rslide">
                            <img src="http://www.grandvincent-marion.fr/_codepen/flower-3.jpg" alt="">
                        </div>

                        <div class="Rslide">
                            <img src="http://www.grandvincent-marion.fr/_codepen/flower-5.jpg" alt="">
                        </div>   
                        <div class="Rslide">
                            <img src="http://www.grandvincent-marion.fr/_codepen/flower-1.jpg" alt="">
                        </div>                                             
                    </div>   

                   
                    <div class="control">
                        <div class="oncontrol control-top">
                            <i class="fa fa-arrow-up" aria-hidden="true"></i>
                        </div>
                        <div class="oncontrol control-bottom">
                            <i class="fa fa-arrow-down" aria-hidden="true"></i>
                        </div>                         
                    </div>

               </div>

           </div>
       </div>

Cuối cùng chèn đoạn mã JS dưới đây nữa là xong:
<script>
var Lslide      = document.querySelectorAll('.Lslide'),
    Rslide      = document.querySelectorAll('.Rslide'),
    control     = document.querySelectorAll('.oncontrol'),
    slideHeight = document.querySelector('.wrapper').clientHeight,
    color = ['#fdc97c', '#e5d3d0', '#71b3d6'],
    index = 0;


function init() {
    slideHeight = document.querySelector('.wrapper').clientHeight;
    for (i = 0; i < Lslide.length; i++) {
        Lslide[i].style.backgroundColor = color[i];
        Lslide[i].style.top = -slideHeight * i + "px";
        Rslide[i].style.top = slideHeight * i + "px";
    } 
}
init()
window.addEventListener('resize', function(){
    init()
});

function moveToTop() {

    index++;
    for (el = 0; el < Lslide.length; el++) {
        Lslide[el].style.top = parseInt(Lslide[el].style.top) + slideHeight + "px";
        Rslide[el].style.top = parseInt(Rslide[el].style.top) - slideHeight + "px";
    }

    if (index > Lslide.length-1) {
        index = 0;
        for (el = 0; el < Lslide.length; el++) {
            Lslide[el].style.top = -slideHeight * el + "px";
            Rslide[el].style.top = slideHeight * el + "px";
        }
    }
}

function moveToBottom() {
    index--;
    for (el = 0; el < Lslide.length; el++) {
        Lslide[el].style.top = parseInt(Lslide[el].style.top) - slideHeight + "px";
        Rslide[el].style.top = parseInt(Rslide[el].style.top) + slideHeight + "px";
       
    }
    if (index < 0) {
        index = Rslide.length-1;
        for (el = 0; el < Lslide.length; el++) {
            Lslide[el].style.top = parseInt(Lslide[el].style.top) + slideHeight * Lslide.length + "px";
            Rslide[el].style.top = parseInt(Rslide[el].style.top) - slideHeight * Rslide.length + "px";
        }
    }
}

function transition() {
    for (t = 0; t < Lslide.length; t++) {
        Lslide[t].style.transition = "all 0.8s";
        Rslide[t].style.transition = "all 0.8s";
    }
}
 

for (t = 0; t < control.length; t++) {
    control[t].addEventListener("click", function() {

        if (this.classList.contains('control-top')) {
            moveToTop()
        }
        if (this.classList.contains('control-bottom')) {
            moveToBottom()
        }

        transition()
 
    });
}

var wheeling;
function mousemouve(e) {

    clearTimeout(wheeling);
    e.preventDefault();
    var e = window.event || e;
    var delta = Math.max(-1, Math.min(1, (e.wheelDelta || -e.detail)));
   
    wheeling = setTimeout(function() {
        wheeling = undefined;
        if (delta === 1) {
            moveToTop()
        }
        if (delta === -1) {
            moveToBottom()
        }
    }, 100);

    transition()
}

document.addEventListener("mousewheel", mousemouve);
document.addEventListener("DOMMouseScroll", mousemouve);
</script>
CÓ THỂ BẠN ĐANG TÌM
  • Thẻ điều kiện blogger 2018
    Thẻ điều kiện blogger 2018
    18/05/2018 - 0 bình luận
    Dưới đây là danh sách thẻ cũ và thẻ mới được cập nhật và cách sử dụngPhần I. Các thẻ điều kiện1. Trang chủ (Hom…
  • Hiệu ứng Canvas
    Hiệu ứng Canvas
    30/11/2018 - 0 bình luận
    DemoĐầu tiên chèn CSS:canvas { position: absolute; top: 0; left: 0; }Tiếp đến là đoạn code dán vào nơi hiển thị…
  • Template Blogspot Games APK Download 2018
    Template Blogspot Games APK Download 2018
    14/05/2018 - 0 bình luận
    Demo   Liên hệ#Template Blogspot #Template Blogspot Games  #Template Blogspot APPS
  • Tạo dropdown label (nhãn) cho blogspot
    Tạo dropdown label (nhãn) cho blogspot
    22/05/2018 - 0 bình luận
    Nhãn (Label, Tags, Categories...) là một thành phần rất quan trọng khi bạn sử dụng nền tảng blogger. Nhãn giúp …
  • Code Nút Social share cho blogspot Blogger
    Code Nút Social share cho blogspot Blogger
    21/05/2018 - 0 bình luận
    Button chia sẻ bài viết lên các trang mạng xã hội là 1 thành phần không thể thiếu với mỗi template blogger. Việ…
  • CSS Hiệu Ứng Thầy Trò Tây Du Ký Thỉnh Kinh
    CSS Hiệu Ứng Thầy Trò Tây Du Ký Thỉnh Kinh
    08/07/2018 - 0 bình luận
    DemoChèn CSS dưới vào:* { padding: 0; margin: 0; list-style: none; } html,body { height: 100%; } .main { h…
  • Thay đổi Avatar thành viên nào đó của comment Blogger
    Thay đổi Avatar thành viên nào đó của comment Blogger
    20/05/2018 - 0 bình luận
    Khi bạn sử dụng hệ thống bình luận mà blogger cung cấp, nếu như hồ sơ người dùng chưa có avatar thì blogger sẽ …
  • Tạo khung chứa code có nút copy to clipboard cho blogspot
    Tạo khung chứa code có nút copy to clipboard cho blogspot
    24/05/2018 - 0 bình luận
    Để làm được điều đó thì bạn cần các công cụ sauFontawesome để cho nút copy thêm sinh độngJQuery: cái này thì hầ…
  • Menu ẩn hiện dạng Material Design cho blogspot
    Menu ẩn hiện dạng Material Design cho blogspot
    21/05/2018 - 0 bình luận
    Menu là thành phần không thể thiếu đối với mỗi website, 1 thanh menu chưa đủ với bạn ? bạn cần 1 thanh menu ẩn …
  • Code Slider Post Làm Trang Chủ
    Code Slider Post Làm Trang Chủ
    25/05/2018 - 0 bình luận
    DemoĐầu tiên chèn đoạn css dưới:<link href="css/style.css" rel="stylesheet" type="text/css"></link>…
  • Nâng cấp Blogger Layout, Default Widget và Skin lên phiên bản mới
    Nâng cấp Blogger Layout, Default Widget và Skin lên phiên bản mới
    25/05/2018 - 0 bình luận
    Vừa qua Google có tung ra gói theme blogger mới khá đẹp mắt với chức năng tùy chỉnh cao hơn. Tuy nhiên với hầu …
  • Code Tùy Biến Thumbnail Cho Blogspot
    Code Tùy Biến Thumbnail Cho Blogspot
    17/05/2018 - 0 bình luận
    1. Sử dụng JS* Với auto read more+ FORM 1: Cấu trúc dạng<div class='block-image'> <div class='thumb…