Yapmaya çalıştığım şey, ipucu rengini kırmızıya çevirmek . Bununla birlikte, birden fazla başka renge de sahip olmak istiyorum, bu nedenle orijinal araç ipucunun rengini değiştirmek istemiyorum.
Bunu nasıl yapacağım?
Yapmaya çalıştığım şey, ipucu rengini kırmızıya çevirmek . Bununla birlikte, birden fazla başka renge de sahip olmak istiyorum, bu nedenle orijinal araç ipucunun rengini değiştirmek istemiyorum.
Bunu nasıl yapacağım?
Yanıtlar:
Bu şekilde kullanabilirsiniz:
<a href="#" data-toggle="tooltip" data-placement="bottom"
title="" data-original-title="Tooltip on bottom"
class="red-tooltip">Tooltip on bottom</a>
Ve CSS'de:
.tooltip-arrow,
.red-tooltip + .tooltip > .tooltip-inner {background-color: #f00;}
Moeen MH : Bootstrap'in en yeni sürümüyle, siyah oktan kurtulmak için bunu yapmanız gerekebilir:
.red-tooltip + .tooltip.top > .tooltip-arrow {background-color: #f00;}
Bootstrap 4 için bunu kullanın:
.bs-tooltip-auto[x-placement^=bottom] .arrow::before,
.bs-tooltip-bottom .arrow::before {
border-bottom-color: #f00; /* Red */
}
Tam Snippet:
$(function() {
$('[data-toggle="tooltip"]').tooltip()
})
.tooltip-main {
width: 15px;
height: 15px;
border-radius: 50%;
font-weight: 700;
background: #f3f3f3;
border: 1px solid #737373;
color: #737373;
margin: 4px 121px 0 5px;
float: right;
text-align: left !important;
}
.tooltip-qm {
float: left;
margin: -2px 0px 3px 4px;
font-size: 12px;
}
.tooltip-inner {
max-width: 236px !important;
height: 76px;
font-size: 12px;
padding: 10px 15px 10px 20px;
background: #FFFFFF;
color: rgb(0, 0, 0, .7);
border: 1px solid #737373;
text-align: left;
}
.tooltip.show {
opacity: 1;
}
.bs-tooltip-auto[x-placement^=bottom] .arrow::before,
.bs-tooltip-bottom .arrow::before {
border-bottom-color: #f00;
/* Red */
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.bundle.min.js"></script>
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet" />
<div class="tooltip-main" data-toggle="tooltip" data-placement="top" data-original-title="Hello world"><span class="tooltip-qm">?</span></div>
<style>
.bs-tooltip-auto[x-placement^=bottom] .arrow::before,
.bs-tooltip-bottom .arrow::before {
border-bottom-color: #f00;
/* Red */
}
</style>
.red-tooltip + .tooltip > .tooltip-arrow {background-color: #f00;}
.red-tooltip + .tooltip.top > .tooltip-arrow {background-color: #f00;}
containerseçeneğini varsayılan olarak bırakırsanız bu çözüm işe yarar . Ancak, container: "body"ipucunuzun taşma olarak kırpılmaması için yaparsanız , bu css seçiciyi bozar.
Önyükleme 2
İmleci / oku da değiştirmek istiyorsanız, aşağıdakileri yapın:
.red-tooltip + .tooltip > .tooltip-inner {background-color: #f00;}
.red-tooltip + .tooltip > .tooltip-arrow {border-bottom-color: #f00;}
veya
.red-tooltip + .tooltip > .tooltip-inner, .red-tooltip + .tooltip > .tooltip-arrow {background-color: #f00;}
jsFiddle: http://jsfiddle.net/technotarek/2htZe/
GÜNCELLEME: Bootstrap 3
Bootstrap 3'teki araç ipucunun yönüne spesifik olmalısınız. Örneğin:
.tooltip.top .tooltip-inner {
background-color:red;
}
.tooltip.top .tooltip-arrow {
border-top-color: red;
}
Bootstrap 3 kullanarak tüm araç ipucu yönergeleri için jsFiddle: http://jsfiddle.net/technotarek/L2rLE/
Benim için çalışmanın tek yolu:
$(document).ready(function() {
//initializing tooltip
$('[data-toggle="tooltip"]').tooltip();
});
.tooltip-inner {
background-color: #00acd6 !important;
/*!important is not necessary if you place custom.css at the end of your css calls. For the purpose of this demo, it seems to be required in SO snippet*/
color: #fff;
}
.tooltip.top .tooltip-arrow {
border-top-color: #00acd6;
}
.tooltip.right .tooltip-arrow {
border-right-color: #00acd6;
}
.tooltip.bottom .tooltip-arrow {
border-bottom-color: #00acd6;
}
.tooltip.left .tooltip-arrow {
border-left-color: #00acd6;
}
<!--jQuery-->
<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
<!--tether-->
<script src="https://cdnjs.cloudflare.com/ajax/libs/tether/1.4.0/js/tether.min.js"></script>
<!--Bootstrap-->
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" rel="stylesheet" />
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/js/bootstrap.min.js"></script>
<!--Tooltip Example-->
<div style="padding:50px;">
<span class="fa-stack fa-lg" data-toggle="tooltip" data-placement="right" title="custom colored tooltip">hover over me
</span>
</div>
Bootstrap4 için şu kodu kullandım:
.tooltip-inner {
background-color: #color !important;
color: #color ;
}
.bs-tooltip-top .arrow::before, .bs-tooltip-auto[x-placement^="top"] .arrow::before {
border-top-color: #color !important;
}
.bs-tooltip-right .arrow::before, .bs-tooltip-auto[x-placement^="right"] .arrow::before {
border-right-color: #color !important;
}
.bs-tooltip-bottom .arrow::before, .bs-tooltip-auto[x-placement^="bottom"] .arrow::before {
border-bottom-color: #color !important;
}
.bs-tooltip-left .arrow::before, .bs-tooltip-auto[x-placement^="left"] .arrow::before {
border-left-color: #color !important;
}
İşte boostrap'taki araç ipucu kodu ...
.tooltip {
position: absolute;
z-index: 1070;
display: block;
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
font-size: 12px;
font-style: normal;
font-weight: normal;
line-height: 1.42857143;
text-align: left;
text-align: start;
text-decoration: none;
text-shadow: none;
text-transform: none;
letter-spacing: normal;
word-break: normal;
word-spacing: normal;
word-wrap: normal;
white-space: normal;
filter: alpha(opacity=0);
opacity: 0;
line-break: auto;
}
.tooltip.in {
filter: alpha(opacity=90);
opacity: .9;
}
.tooltip.top {
padding: 5px 0;
margin-top: -3px;
}
.tooltip.right {
padding: 0 5px;
margin-left: 3px;
}
.tooltip.bottom {
padding: 5px 0;
margin-top: 3px;
}
.tooltip.left {
padding: 0 5px;
margin-left: -3px;
}
.tooltip-inner {
max-width: 200px;
padding: 3px 8px;
color: #fff;
text-align: center;
background-color: #000;
border-radius: 4px;
}
.tooltip-arrow {
position: absolute;
width: 0;
height: 0;
border-color: transparent;
border-style: solid;
}
.tooltip.top .tooltip-arrow {
bottom: 0;
left: 50%;
margin-left: -5px;
border-width: 5px 5px 0;
border-top-color: #000;
}
.tooltip.top-left .tooltip-arrow {
right: 5px;
bottom: 0;
margin-bottom: -5px;
border-width: 5px 5px 0;
border-top-color: #000;
}
.tooltip.top-right .tooltip-arrow {
bottom: 0;
left: 5px;
margin-bottom: -5px;
border-width: 5px 5px 0;
border-top-color: #000;
}
.tooltip.right .tooltip-arrow {
top: 50%;
left: 0;
margin-top: -5px;
border-width: 5px 5px 5px 0;
border-right-color: #000;
}
.tooltip.left .tooltip-arrow {
top: 50%;
right: 0;
margin-top: -5px;
border-width: 5px 0 5px 5px;
border-left-color: #000;
}
.tooltip.bottom .tooltip-arrow {
top: 0;
left: 50%;
margin-left: -5px;
border-width: 0 5px 5px;
border-bottom-color: #000;
}
.tooltip.bottom-left .tooltip-arrow {
top: 0;
right: 5px;
margin-top: -5px;
border-width: 0 5px 5px;
border-bottom-color: #000;
}
.tooltip.bottom-right .tooltip-arrow {
top: 0;
left: 5px;
margin-top: -5px;
border-width: 0 5px 5px;
border-bottom-color: #000;
}
Bootstrap 4'ten itibaren bu stilleri doğrudan Bootstrap Sass değişkenler dosyanızdan özelleştirebileceğinizi unutmayın, bu nedenle _variables.scss'de şu seçeneklere sahipsiniz:
//== Tooltips
//
//##
// ** Tooltip max width
$tooltip-max-width: 200px !default;
// ** Tooltip text color
$tooltip-color: #fff !default;
// ** Tooltip background color
$tooltip-bg: #000 !default;
$tooltip-opacity: .9 !default;
// ** Tooltip arrow width
$tooltip-arrow-width: 5px !default;
// ** Tooltip arrow color
$tooltip-arrow-color: $tooltip-bg !default;
Buraya bakın: http://v4-alpha.getbootstrap.com/getting-started/options/
Sass'ta çalışmak ve Grunt veya Gulp oluşturma araçlarıyla ilerledikçe derlemek en iyisidir.
jQuery düzeltmem:
HTML:
<a href="#" data-toggle="tooltip" data-placement="right" data-original-title="some text">
<span class="glyphicon glyphicon-question-sign"></span>
</a>
jQuery:
$('[data-toggle="tooltip"]').hover(function(){
$('.tooltip-inner').css('min-width', '400px');
$('.tooltip-inner').css('color', 'red');
});
Probleminizi çözmek için bunu kullanabilirsiniz. Projemde kontrol ettim ve iyi çalışıyor.
<a class="btn btn-sm btn-success media-tooltip" href="#" data-toggle="tooltip" data-placement="bottom" title="Download Now">Download Now</a>
.media-tooltip + .tooltip .tooltip-inner {
font-size: 14px;
font-weight: 700;
color: rgb( 37, 207, 187 );
border-width: 1px;
border-color: rgb( 37, 207, 187 );
border-style: solid;
background-color: rgb( 219, 242, 239 );
padding: 10px;
border-radius: 0;
}
.media-tooltip + .tooltip > .tooltip-arrow{display: none;}
.media-tooltip + .tooltip .tooltip-inner:after, .media-tooltip + .tooltip .tooltip-inner:before {
bottom: 89%;
left: 50%;
border: solid transparent;
content: " ";
height: 0;
width: 0;
position: absolute;
pointer-events: none;
}
.media-tooltip + .tooltip .tooltip-inner:after {
border-color: rgba(219, 242, 239, 0);
border-bottom-color: #dbf2ef;
border-width: 10px;
margin-left: -10px;
}
.media-tooltip + .tooltip .tooltip-inner:before {
border-color: rgba(37, 207, 187, 0);
border-bottom-color: #25cfbb;
border-width: 11px;
margin-left: -11px;
}
Bu zaten doğru cevaplandı ama bence ben de fikrimi vermeliyim. Cozen'in dediği gibi, bunun bir sınır olduğunu ve çalışabilmesi için, bootstrap'in belirttiği şekilde bunu biçimlendirmek için sınıfları belirlemelisiniz. Yani bunu yapabilirsin
.tooltip .tooltip-inner {background-color: #00a8c4; color: black;}
.tooltip.top .tooltip-arrow {border-top-color: #00a8c4;}
veya bir sonrakini sadece araç ipucu oku için yapabilirsiniz, ancak önyükleme css'nin üzerine yazması için!
.tooltip-arrow {border-top-color: #00a8c4!important;}
Bu benim için çalıştı.
.tooltip .arrow:before {
border-top-color: #008ec3 !important;
}
.tooltip .tooltip-inner {
background-color: #008ec3;
}
Yukarıdaki cevapların hiçbiri durumunda iyi çalışır container: 'body've aşağıdaki çözüm işe yarar :
// Assign custom CSS class after the tooltip template has been added to the DOM
$(document).on('inserted.bs.tooltip', function(e) {
var tooltip = $(e.target).data('bs.tooltip');
tooltip.$tip.addClass($(e.target).data('tooltip-custom-class'));
});
Ve basit bir CSS pasajı:
.tooltip.tooltip-danger > .tooltip-inner {
background-color: #d9534f;
}
.tooltip.tooltip-danger.left > .tooltip-arrow {
border-left-color: #d9534f;
}
Artık araç ipucunuzu her zamanki gibi, özel CSS sınıfını data-tooltip-custom-classöznitelik yoluyla geçirebilirsiniz :
<span class="js-tooltip">Hover me totally</span>
<script>
$('.js-tooltip')
.data('tooltip-custom-class', 'tooltip-danger')
.tooltip(/*your options*/)
;
</script>
BootStrap 4
BootStrap 4 kullanılırken, araç ipucu gövde etiketinin altına eklenir. Araç ipucunuz başka bir etiketin alt öğesiyse, ipucunu css kullanarak hedeflemenin bir yolu yoktur. İşe yaradığını bulmamın tek yolu, insert.bs.tooltip olayını kullanmak ve iç div ve oka bir sınıf eklemektir. Daha sonra css'deki sınıfı hedefleyebilirsiniz.
// initialize tooltips
$('[data-toggle="tooltip"]').tooltip();
// Add the classes to the toolip when it is created
$('[data-toggle="tooltip"]').on('inserted.bs.tooltip',function () {
var thisClass = $(this).attr("class");
$('.tooltip-inner').addClass(thisClass);
$('.arrow').addClass(thisClass + "-arrow");
});
/* style the tooltip box and arrow based on your class*/
.bs-tooltip-left .redTip {
background-color: red !important
}
.bs-tooltip-left .redTip-arrow::before {
border-left-color: red !important
}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
<p>Show a red tooltip <a href="#" class="redTip" data-toggle="tooltip" data-placement="left" title="You Did It!">Hover over me</a></p>
Sadece rengini değiştirmek istiyorsanız, diğer cevaplarda belirtilen hızlı yaklaşımı kullanabilirsiniz. Ancak Bootstrap kullanıyorsanız, görünüm ve his tutarlı olması için temaları kullanmanız gerekir. Maalesef Bootstrap temaları için yerleşik bir destek yok, bu yüzden bunu yapan küçük CSS parçası yazdım. Temel olarak tooltip-info, tooltip-warningtemayı uygulamak için öğeye ekleyebileceğiniz vb. Sınıflar alırsınız .
Bu kodu keman, örnekler ve daha fazla açıklamayla birlikte bu yanıtta bulabilirsiniz: https://stackoverflow.com/a/20880312/207661
Ok bir sınırdır.
Her ok için karşılık gelen rengi değiştirmeniz gerekir.
.tooltip.top .tooltip-arrow {
border-top-color: @color;
}
.tooltip.top-left .tooltip-arrow {
border-top-color: @color;
}
.tooltip.top-right .tooltip-arrow {
border-top-color:@color;
}
.tooltip.right .tooltip-arrow {
border-right-color: @color;
}
.tooltip.left .tooltip-arrow {
border-left-color: @color;
}
.tooltip.bottom .tooltip-arrow {
border-bottom-color: @color;
}
.tooltip.bottom-left .tooltip-arrow {
border-bottom-color: @color;
}
.tooltip.bottom-right .tooltip-arrow {
border-bottom-color: @color;
}
.tooltip > .tooltip-inner {
background-color: @color;
font-size: @font-size-small;
}
Bununla birlikte, rengi değiştirmek için bir sınıf eklemek istersem ('.class + .tooltip ...' ile olduğu gibi, işe yaramaz (bootstrap 3).
Birisi bununla nasıl başa çıkacağını biliyorsa?!?
Ok için önce hangi yönü kullandığınızı onaylayın. Örneğin, leftyön kullanıyorum , o zaman olmalı
.tooltip .tooltip-inner {
background-color:#2fa5fb;
}
.tooltip.left > .tooltip-arrow {
border-left-color: #2fa5fb;
}
Bootstrap4'teki araç ipucunun rengini değiştirecek, altta, solda, sağda CSS eklemek için üst yerine .bs-tooltip-top içinde CSS eklemek için kullanabilirsiniz.
.tooltip-inner {
background-color: #00acd6 !important;
color: #fff;
}
.bs-tooltip-top .arrow::before, .bs-tooltip-auto[x-placement^="top"]
.arrow::before {
border-top-color: #00acd6;
}
Ok (aynı zamanda ok için kenarlık ve arka plan) dahil olmak üzere araç ipucu renklerini kolayca kontrol etmenize yardımcı olacak bir SCSS kodu (aşağıda derlenmiş css):
Not: CSS kurallarının yürürlüğe girmesi için bazı yerlere "önemli" eklemeniz gerekebilir. Not # 2: Buradaki stil yalnızca TOP ve BOTTOM araç ipucu düzenlerinde çalışır. Biraz daha stil eklemekten çekinmeyin (& .bs-tooltip-left, & .bs-tooltip-right, vb.)
SCSS :
$tt-text-color: lime;
$tt-border-color: lime;
$tt-bg-color: black;
$arrow-border-color: lime;
$arrow-bg-color: black;
.tooltip {
.tooltip-inner {
background: $tt-bg-color;
color: $tt-text-color;
border: 2px solid $tt-border-color;
}
.arrow {
width: 11px;
height: 11px;
border: 2px solid $arrow-border-color;
bottom: 1px;
&:before {
width: 11px;
height: 11px;
background: $arrow-bg-color;
border: 0;
}
}
&.bs-tooltip-top {
.arrow {
transform: rotate(-135deg);
}
}
&.bs-tooltip-bottom {
.arrow {
transform: rotate(135deg);
top: 2px;
}
}
}
CSS :
.tooltip .tooltip-inner {
background: black;
color: lime;
border: 2px solid lime;
}
.tooltip .arrow {
width: 11px;
height: 11px;
border: 2px solid lime;
bottom: 1px;
}
.tooltip .arrow:before {
width: 11px;
height: 11px;
background: black;
border: 0;
}
.tooltip.bs-tooltip-top .arrow {
transform: rotate(-135deg);
}
.tooltip.bs-tooltip-bottom .arrow {
transform: rotate(135deg);
top: 2px;
}
Canlı Örnek:
jQuery(document).ready(function(){
$('a').tooltip();
});
.tooltip .tooltip-inner {
background: black;
color: lime;
border: 2px solid lime;
}
.tooltip .arrow {
width: 11px!important;
height: 11px!important;
border: 2px solid lime;
bottom: 1px;
}
.tooltip .arrow:before {
width: 11px;
height: 11px;
background: black;
border: 0;
}
.tooltip.bs-tooltip-top .arrow {
transform: rotate(-135deg);
}
.tooltip.bs-tooltip-bottom .arrow {
transform: rotate(135deg);
top: 2px;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.4.1/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.4.1/js/bootstrap.bundle.min.js"></script>
<div class="text-center py-4">
<a class="cn-box big cn-copy" data-toggle="tooltip" data-placement="bottom" title="Hello There">
try me
</a>
</div>
$(document).ready(function(){
$('.tooltips-elements')
.tooltip()
.each(function() {
var color = $(this).data('color');
$(this).hover(function(){
var aria = $(this).attr('aria-describedby');
$('#' + aria).find('.tooltip-inner').css({
"background": color,
"color" : "#333",
"margin-left" : "10px",
"font-weight" : "700",
"font-family" : "Open Sans",
"font-size" : "13px",
});
$('#' + aria).find('.tooltip-arrow').css({
"border-bottom-color" : color,
});
});
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>
<a href="#" class="tooltips-elements" data-toggle="tooltip" data-placement="bottom" data-original-title="Here comes the tooltip" data-color="red">Hover me</a>
Bunu kontrol et, belki sana yardımcı olabilir. Birden çok araç ipucu rengine sahip olabilirsiniz.
Web sitemizde önyükleme 3.0 kullanıyoruz, ancak yukarıdaki adımların hiçbiri araç ipucunun stilini güncellemede işe yaramadı. Ancak bunun yerine jQueryUI stilini kullanarak bir çözüm buldum
https://jqueryui.com/tooltip/#custom-style
CSS
.ui-tooltip, .arrow:after {
background: black;
border: 2px solid white;
}
.ui-tooltip {
padding: 10px 20px;
color: white;
border-radius: 20px;
font: bold 14px "Helvetica Neue", Sans-Serif;
text-transform: uppercase;
box-shadow: 0 0 7px black;
}
HTML
<div class="qu_help" data-toggle="tooltip" title="Some Random Title">
<span class="glyphicon glyphicon-question-sign" aria-hidden="true"></span>
</div>
Başka birinin de benimle benzer bir durumda olması durumunda bu cevabı ekliyorum.
Bu kolay yöntem, önyükleme araç ipuçlarının arka plan rengini değiştirmek istediğimde işe yarar:
$(function(){
//$('.tooltips.red-tooltip').tooltip().data('bs.tooltip').tip().addClass('red-tooltip');
$('.tooltips.red-tooltip').tooltip().data('tooltip').tip().addClass('red-tooltip');
});
.red-tooltip.tooltip.tooltip.bottom .tooltip-arrow,
.red-tooltip.tooltip.tooltip.bottom-left .tooltip-arrow,
.red-tooltip.tooltip.tooltip.bottom-right .tooltip-arrow{border-bottom-color: red;}
.red-tooltip.tooltip.top .tooltip-arrow {border-top-color: red;}
.red-tooltip.tooltip.left .tooltip-arrow {border-left-color: red;}
.red-tooltip.tooltip.right .tooltip-arrow {border-right-color: red;}
.red-tooltip.tooltip > .tooltip-inner{background-color:red;}
<link href="http://getbootstrap.com/2.3.2/assets/css/bootstrap.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
<script src="http://getbootstrap.com/2.3.2/assets/js/bootstrap-tooltip.js"></script>
<a href="#" data-toggle="tooltip" data-placement="bottom"
title="" data-original-title="Made by @Ram"
class="tooltips red-tooltip">My link with red tooltip</a>
Çay yok:
Eğer
jskod içerir.data('tooltip')sizin için çalışmıyor sonra lütfen kendi çizgisini açıklama ve yorumsuzjskod içerir.data('bs-tooltip').Not B:
Eğer sizin önyükleme ipucu işlevi, bir araç ipucu eklemek vücudun sonunda (değil doğru elemana sonra) için , benim çözüm de henüz çalışır ancak bu sayfalarında başka cevaplar vermedi gibi çalışır @Praveen Kumar ve @technoTarek bu senaryoda.
Not C:
Bu kodlar destek
tooltip arrowaraç ipucu tüm yerleşimlerde renk (top,bottom,left,right).
Tether.js bağımlılığına sahip Bootstrap 4 için .tooltip-arrow sınıfları .tooltip.bs-tether-element-ekli- [position] ile değiştirildi {...}
İşte rengini nasıl değiştirdim ve alt oku kalınlaştırdım. Kenar genişliğine eklenen her piksel için, "alt" konumdan bir piksel çıkarmak zorunda kaldım.
.tooltip.bs-tether-element-attached-bottom .tooltip-inner::before, .tooltip.tooltip-bottom .tooltip-inner::before {
border-top-color: #d19b3d !important;
border-width: 10px 10px 0;
bottom: -5px;
}
Diğer konumlar için ayarlamanız gerekecek, yani .tooltip.bs-tether-element-ekli-left için border-right'ı ayarlayacak ve "soldan" pikselleri çıkararak border-genişliğini yükseltirseniz yeniden konumlandıracaksınız.
Oleg'in cevabı https://stackoverflow.com/a/42994192/9921853 orada en iyisidir. Araç ipucu stillerinin dinamik olarak oluşturulan öğelere uygulanmasına izin verir. Ancak Bootstrap 4 için çalışmaz. Biraz değiştirilmelidir:
Önyükleme 3:
$(document).on('inserted.bs.tooltip', function(e) {
var tooltip = $(e.target).data('bs.tooltip');
tooltip.$tip.addClass($(e.target).data('tooltip-custom-class'));
});
Örnek: https://www.bootply.com/UORR04ncTP
Önyükleme 4:
$(document).on('inserted.bs.tooltip', function(e) {
var tooltip = $(e.target).data('bs.tooltip');
$(tooltip.tip).addClass($(e.target).data('tooltip-custom-class'));
});
Örnek: https://jsfiddle.net/nsmcan/naq530hx
Tam Çözüm (Bootstrap 3)
JS
$(document).on('inserted.bs.tooltip', function(e) {
var tooltip = $(e.target).data('bs.tooltip');
tooltip.$tip.addClass($(e.target).data('tooltip-custom-classes'));
});
$('body').tooltip({
selector: "[title]",
html: true
});
HTML
<h1>Test tooltip styling</h1>
<div><span title="Long-long-long tooltip doesn't fit the single line">Hover over me 1</span></div>
<div><span data-tooltip-custom-classes="tooltip-left" data-container="body" title="Example (left aligned):<br>Tooltip doesn't fit the single line, and is not a sibling">Hover over me 2</span></div>
<div><span class="text-danger" data-tooltip-custom-classes="tooltip-large tooltip-left tooltip-danger" title="Example (left aligned):<br>This long text we want to have in the single line">Hover over me 3</span></div>
CSS
.tooltip.tooltip-large > .tooltip-inner {
max-width: 300px;
}
.tooltip.tooltip-left > .tooltip-inner {
text-align: left;
}
.tooltip.top.tooltip-danger > .tooltip-arrow {
border-top-color: #d9534f;
}
.tooltip.top-left.tooltip-danger > .tooltip-arrow {
border-top-color: #d9534f;
}
.tooltip.top-right.tooltip-danger > .tooltip-arrow {
border-top-color:#d9534f;
}
.tooltip.right.tooltip-danger > .tooltip-arrow {
border-right-color: #d9534f;
}
.tooltip.left.tooltip-danger > .tooltip-arrow {
border-left-color: #d9534f;
}
.tooltip.bottom.tooltip-danger > .tooltip-arrow {
border-bottom-color: #d9534f;
}
.tooltip.bottom-left.tooltip-danger > .tooltip-arrow {
border-bottom-color: #d9534f;
}
.tooltip.bottom-right.tooltip-danger > .tooltip-arrow {
border-bottom-color: #d9534f;
}
.tooltip.tooltip-danger > .tooltip-inner {
background-color: #d9534f;
}
için Bootstrap 4CSS aracılığıyla sürümü :
Balonun arka plan rengini değiştirmek istiyorsanız :
/* change style balloon */
.tooltip-inner {
background-color: green !important;
color: #fff;
}
alt konumda göründüğünde oku değiştirmek isterseniz :
/* change style arrow */
.bs-tooltip-auto[x-placement^=bottom] .arrow::before, .bs-tooltip-bottom .arrow::before {
border-bottom-color: #f00;
}
Umarım sana yardım eder
BS4 projenizde, SASS kodunu derleyebiliyorsanız, araç ipuçlarının renk şemasını herhangi bir yönden yönetmek için bir karışım oluşturma avantajından yararlanabilirsiniz.
İşte bunu uygulayabileceğiniz birçok yoldan biri:
Bir liste oluşturun ve 4 olası yönün tamamını kapsayacak şekilde üzerinde döngü yapın
//define a color
$m-color-blue: #004c97;
//create a mixin with parameters and default value
@mixin m-tooltip-color-direction($name:'.mtootltip', $color:$m-color-blue) {
//reference your custom class name
#{$name} {
.tooltip-inner {
background-color: $color;
}
//create a list of possible directions
$directions: top bottom left right;
//loop through the list
@each $direction in $directions {
&.bs-tooltip-#{$direction} .arrow:before,
.bs-tooltip-auto[x-placement^="$direction"] .arrow:before {
border-#{$direction}-color: $color !important;
}
}
}
}
Ana .scss dosyanız içinde miksinizi şu şekilde çağırın:
@include m-tooltip-color-direction('.mtooltip', $m-color-blue);Son olarak, düzeninize bir BS4 araç ipucu ekleyin ve ona esneklik için özel bir sınıf verin. Bu BS4 kaynağı şablonun bir seçenek olarak kullanılmasından bahsediyor. Bunu özel sınıfımızı eklemek için kullanacağız.
Aşağıdaki örnek, bir bilgi simgesi rozetine bir ipucu ekler:
<span class="badge badge-pill badge-primary" data-toggle="tooltip" data-placement="right" data-html="true" data-template="<div class='tooltip mtooltip' role='tooltip'><div class='arrow'></div><div class='tooltip-inner'></div></div>" title="<h1 class='text-white'>Tooltip</h1> on bottom">i</span>Bu kurulumla , orijinal miksinize dokunmadan araç ipucunuzun sınıf adını, rengini ve yönünü ayarlayabilirsiniz . Ne kadar serin :)
Bu yardımcı olur umarım!