2017-01-12 18 views
0

訪問いただきありがとうございます。 私の背中合わせのボタンに「テキスト」と言って「」と言っているようなものを追加するにはどうすればいいですか?方法:戻るトップボタンにテキストを追加

jQuery(document).ready(function($){ 
 
\t // browser window scroll (in pixels) after which the "back to top" link is shown 
 
\t var offset = 300, 
 
\t \t //browser window scroll (in pixels) after which the "back to top" link opacity is reduced 
 
\t \t offset_opacity = 1200, 
 
\t \t //duration of the top scrolling animation (in ms) 
 
\t \t scroll_top_duration = 700, 
 
\t \t //grab the "back to top" link 
 
\t \t $back_to_top = $('.cd-top'); 
 

 
\t //hide or show the "back to top" link 
 
\t $(window).scroll(function(){ 
 
\t \t ($(this).scrollTop() > offset) ? $back_to_top.addClass('cd-is-visible') : $back_to_top.removeClass('cd-is-visible cd-fade-out'); 
 
\t \t if($(this).scrollTop() > offset_opacity) { 
 
\t \t \t $back_to_top.addClass('cd-fade-out'); 
 
\t \t } 
 
\t }); 
 

 
\t //smooth scroll to top 
 
\t $back_to_top.on('click', function(event){ 
 
\t \t event.preventDefault(); 
 
\t \t $('body,html').animate({ 
 
\t \t \t scrollTop: 0 , 
 
\t \t \t }, scroll_top_duration 
 
\t \t); 
 
\t }); 
 

 
});
body { 
 
    width:100%; 
 
    height:1200px; 
 
    background-color:#242424; 
 
    margin:0; 
 
    padding:0; 
 
} 
 
body > div { 
 
    width:100%; 
 
    height:75px; 
 
    background-color:#393939; 
 
    text-align:center; 
 
    position:fixed; 
 
    } 
 
.text { 
 
    font-size:40px; 
 
    color:white; 
 
    line-height:75px; 
 
    } 
 
.cd-container { 
 
    width: 90%; 
 
    max-width: 768px; 
 
    margin: 2em auto; 
 
} 
 
.cd-container::after { 
 
    content: ''; 
 
    display: table; 
 
    clear: both; 
 
} 
 
.cd-top { 
 
    display: inline-block; 
 
    height: 40px; 
 
    width: 80px; 
 
    position: fixed; 
 
    bottom: 40px; 
 
    right: 10px; 
 
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.05); 
 
    overflow: hidden; 
 
    text-indent: 100%; 
 
    white-space: nowrap; 
 
    background: rgba(231, 142, 46, 0.8) url(https://codyhouse.co/demo/back-to-top/img/cd-top-arrow.svg) no-repeat center 50%; 
 
    visibility: hidden; 
 
    opacity: 0; 
 
    -webkit-transition: opacity .3s 0s, visibility 0s .3s; 
 
    -moz-transition: opacity .3s 0s, visibility 0s .3s; 
 
    transition: opacity .3s 0s, visibility 0s .3s; 
 
} 
 
.cd-top.cd-is-visible, .cd-top.cd-fade-out, .no-touch .cd-top:hover { 
 
    -webkit-transition: opacity .3s 0s, visibility 0s 0s; 
 
    -moz-transition: opacity .3s 0s, visibility 0s 0s; 
 
    transition: opacity .3s 0s, visibility 0s 0s; 
 
} 
 
.cd-top.cd-is-visible { 
 
    visibility: visible; 
 
    opacity: 1; 
 
} 
 
.cd-top.cd-fade-out { 
 
    opacity: .5; 
 
} 
 
.no-touch .cd-top:hover { 
 
    color:#1769ff; 
 
    opacity: 1; 
 
} 
 
@media only screen and (min-width: 768px) { 
 
    .cd-top { 
 
    right: 20px; 
 
    bottom: 20px; 
 
    } 
 
} 
 
} 
 
@media only screen and (min-width: 1024px) { 
 
    .cd-top { 
 
    height: 60px; 
 
    width: 60px; 
 
    right: 30px; 
 
    bottom: 30px; 
 
    } 
 
    
 
}
<!doctype html> 
 
<html> 
 
    <head> 
 
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script> 
 
    </head> 
 
<body> 
 
    <div> 
 
    <span class="text"> Scrolldown.</span> 
 
    </div> 
 
<a href="#0" class="cd-top">BackToToP</a> 
 
    <!-- Im using Back to Top from here: 
 
https://codyhouse.co/demo/back-to-top/index.html 
 
--> 
 
    </body> 
 
    
 
</html>
あなたが表示された場合、私は "BackToTop" のテキストが、何が起こった追加。

私はいろいろな方法で試しましたが、どうやっていいのか分かりません。おかげさまで

+0

皆さんにすべての作業を依頼していません。私はちょうど作業を続けるためにガイドやリトルクラムが必要です。 – Juan

答えて

0

text-indent: 100%を削除する必要があります。 これはテキストを元の位置に戻します。


EDIT:あなたのコードと組み合わせる

.cd-top { 
    text-indent: 0; 
    width: auto; 
    line-height: 40px; 
    text-decoration: none; 
    font-family: Arial; 
    color: #FFF; 
    padding: 0 50px 0 20px; 
    background-position: right 20px center; 
} 

.cd-top { 
    display: inline-block; 
    height: 40px; 
    line-height: 40px; 
    width: auto; 
    position: fixed; 
    bottom: 40px; 
    right: 10px; 
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.05); 
    overflow: hidden; 
    font-family: Arial; 
    text-indent: 0; 
    text-decoration: none; 
    color: #FFF; 
    white-space: nowrap; 
    background: rgba(231, 142, 46, 0.8) url(https://codyhouse.co/demo/back-to-top/img/cd-top-arrow.svg) no-repeat right 20px center; 
    padding: 0 50px 0 20px; 
    -webkit-transition: opacity .3s 0s, visibility 0s .3s; 
    -moz-transition: opacity .3s 0s, visibility 0s .3s; 
    transition: opacity .3s 0s, visibility 0s .3s; 
} 

あなたは、テキストが矢印の隣になりたい場合は、このような何かを行うことができます

+0

ああ、私はそれを見たことはありませんでした。ありがとうございました! – Juan

+0

ようこそ。 :)私は矢印と同じ行にテキストを置いた私の更新された答えを確認してください。 – TheYaXxE

+0

ありがとう、100%罰金と私はスタイルの変更などに取り組んでいます – Juan

0

CSSプロパティ 'text-indent'は、問題を与えるものです。それを削除すると、テキストが表示されます。この種のものをデバッグする良い方法は、開発者ツールを使用して要素を検査することです。

+0

ありがとう。今私はテキストの中で、同じ行の下に、または同じ行に表示する必要があります。 – Juan

関連する問題