HTML: удалить a:hover для изображений?

Вариант, который, возможно, немного более практичен, - реализация пользовательского представления Progress Bar.

public class CustomProgressBar extends View
{
    // % value of the progressbar.
    int progressBarValue = 0;

    public CustomProgressBar(Context context)
    {
        super(context);
    }

    public CustomProgressBar(Context context, AttributeSet attrs)
    {
        super(context, attrs);
        progressBarValue = attrs.getAttributeIntValue(null, "progressBarValue", 0);
    }

    public void setValue(int value)
    {
        progressBarValue = value;
        invalidate();
    }

    protected void onDraw(Canvas canvas)
    {
        super.onDraw(canvas);

        float cornerRadius = 30.0f;

        // Draw the background of the bar.
        Paint backgroundPaint = new Paint();
        backgroundPaint.setColor(Color.LTGRAY);
        backgroundPaint.setStyle(Paint.Style.FILL);
        backgroundPaint.setAntiAlias(true);

        RectF backgroundRect = new RectF(0, 0, canvas.getWidth(), canvas.getHeight());
        canvas.drawRoundRect(backgroundRect, cornerRadius, cornerRadius, backgroundPaint);

        // Draw the progress bar.
        Paint barPaint = new Paint();
        barPaint.setColor(Color.GREEN);
        barPaint.setStyle(Paint.Style.FILL);
        barPaint.setAntiAlias(true);

        float progress = (backgroundRect.width() / 100) * progressBarValue;
        RectF barRect = new RectF(0, 0, progress, canvas.getClipBounds().bottom);

        canvas.drawRoundRect(barRect, cornerRadius, cornerRadius, barPaint);

        // Draw progress text in the middle.
        Paint textPaint = new Paint();
        textPaint.setColor(Color.WHITE);
        textPaint.setTextSize(34);

        String text = progressBarValue + "%";
        Rect textBounds = new Rect();

        textPaint.getTextBounds(text, 0, text.length(), textBounds);

        canvas.drawText(text,
                backgroundRect.centerX() - (textBounds.width() / 2),
                backgroundRect.centerY() + (textBounds.height() / 2),
                textPaint);

    }
}

Тогда в вашем макете:


, что дает результат:

Custom progress bar result

11
задан Cyril Gandon 21 July 2011 в 08:41
поделиться

4 ответа

Если вы размещаете изображения вместо встроенных, это сработает и не потребует никаких изменений атрибутов ссылки на изображения, как того требует ответ Стива.

a:hover img {
border: none !important;
display: block;
}
13
ответ дан 3 December 2019 в 05:36
поделиться
a:hover img {border-bottom: 0px;}

Это должно сработать.

7
ответ дан 3 December 2019 в 05:36
поделиться

Не уверен, что это лучшее решение, но оно работает:

    a:link {color: #3366a9; text-decoration: none}
    a:hover {border-bottom: 1px solid black; }

    .aimg:link {color: #3366a9; text-decoration: none}      
    .aimg:hover { border-bottom: none; }

Затем установите якоря с изображениями в них в класс "aimg":

<a class="aimg" href="Test.htm"><img src="images/myimage.gif" /></a>
2
ответ дан 3 December 2019 в 05:36
поделиться

Вы пробовали img {border: none} ?

-1
ответ дан 3 December 2019 в 05:36
поделиться