简体   繁体   中英

Image Hover on Twitter Bootstrap

my name is Enrique and I'm having a problem with the :hover property on Twitter Bootstrap.

I made a rating system with 5 stars, but when a star is "hovered", the stars start to blink, a really mess

When I use the same system without any script, it works fine, that's why I think the problem are on Bootstrap or Jquery.

Here's my site beeing developed: http://apostilaz.pilha.inf.br/detalhaapostila

The stars are above the big green button writed (BAIXAR APOSTILA), when they are empty its hard to see, I know.

Here is a jsfiddle with the same code without any JS and the code below:

http://jsfiddle.net/EnriqueSampaio/kb9a8/

CSS

.avalia {
    width: 90px;
    height: 17px;
    margin: 0 0 20px 0;
    padding: 0;
    list-style: none;
    clear: both;
    position: relative;
    background: url(../img/estrelas.png) no-repeat 0 0;
}

.semestrela {
background-position: 0 0;
}

.umaestrela {
background-position: 0 -18px;
}

.duasestrelas   {
background-position: 0 -36px;
}

.tresestrelas   {
background-position: 0 -54px;
}

.quatroestrelas {
background-position: 0 -72px;
}

.cincoestrelas   {
background-position: 0 -90px;
}

ul.avalia li  {
cursor: pointer;
float: left;
text-indent: -999em;
}

ul.avalia li a  {
position: absolute;
left: 0;
top: 0;
width: 18px;
height: 17px;
text-decoration: none;
z-index: 200;
}

ul.avalia li.uma a  {
left: 0;
}

ul.avalia li.duas a {
left: 17px;
}

ul.avalia li.tres a {
left: 34px;
}

ul.avalia li.quatro a   {
left: 51px;
}

ul.avalia li.cinco a    {
left: 68px;
}

ul.avalia li a:hover    {
z-index: 2;
width: 90px;
height: 17px;
overflow: hidden;
left: 0;
background: url(../img/estrelas.png) no-repeat 0 0;
transition:none !important;
}

ul.avalia li.uma a:hover    {
background-position: 0 -18px;
}

ul.avalia li.duas a:hover    {
background-position: 0 -36px;
}

ul.avalia li.tres a:hover    {
background-position: 0 -54px;
}

ul.avalia li.quatro a:hover    {
background-position: 0 -72px;
}

ul.avalia li.cinco a:hover    {
background-position: 0 -90px;
}

HTML

<ul class="avalia semestrela">
    <li class="uma"><a href="#fakelink" title="1 Estrela">1</a></li>
    <li class="duas"><a href="#fakelink" title="2 Estrelas">2</a></li>
    <li class="tres"><a href="#fakelink" title="3 Estrelas">3</a></li>
    <li class="quatro"><a href="#fakelink" title="4 Estrelas">4</a></li>
    <li class="cinco"><a href="#fakelink" title="5 Estrelas">5</a></li>
</ul>

Thank you!

After inspect your page a little i found you have no problems with the Scripts, your problem is with one of the css files. This one:

<link rel="stylesheet" type="text/css" href="http://apostilaz.pilha.inf.br/public/plugins/ui/css/flat-ui.css" media="all">

That flat-ui.css is adding an special CSS for the a tags:

a {
 color: #16a085;
 text-decoration: none;
 -webkit-transition: 0.25s;
 -moz-transition: 0.25s;
 -o-transition: 0.25s;
 transition: 0.25s;
 -webkit-backface-visibility: hidden;
}

To make your :hover stars work you need to delete the transition property, this is the cause for that behavior you can't go between stars without select the other one.

PD: Tested on your page with the google chrome inspector

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM