Изменить стиль гиперссылок [дубликат]

Чтобы легко понять проблему, предположим, что мы написали этот код:

static void Main(string[] args)
{
    string[] test = new string[3];
    test[0]= "hello1";
    test[1]= "hello2";
    test[2]= "hello3";

    for (int i = 0; i <= 3; i++)
    {
        Console.WriteLine(test[i].ToString());
    }
}

Результат будет:

hello1
hello2
hello3

Unhandled Exception: System.IndexOutOfRangeException: Index was outside the bounds of the array.

Размер массива равен 3 (индексы 0, 1 и 2), но при попытке получить доступ за пределами границ с помощью (3) он выдает исключение.

10
задан sv88erik 25 December 2010 в 20:33
поделиться

5 ответов

CSS:

A.class1 {color:red;}
A.class1:link  {text-decoration: none; color: red;}
A.class1:visited {text-decoration: none; color: red;}
A.class1:hover {text-decoration: underline; color: red;}
A.class1:active {text-decoration: none; color: red;}


A.class2 {color:blue;}
A.class2:link {text-decoration: none; color: blue;}
A.class2:visited {text-decoration: none; color: blue;}
A.class2:hover {text-decoration: underline; color: blue;}
A.class2:active {text-decoration: none; color: blue;}

HTML:

<a href="http://www.google.com" class="class1">Google</a>
<a href="http://stackoverflow.com" class="class2">Stackoverflow</a>

Демо: http://cssdesk.com/qukaq

29
ответ дан sv88erik 20 August 2018 в 17:05
поделиться
2
ответ дан Felix Kling 20 August 2018 в 17:05
поделиться
0
ответ дан Guffa 20 August 2018 в 17:05
поделиться
<a href="http://" style="color: red">RED</a>

<a href="http://" style="color: blue">RED</a>

Как видно выше, вы просто вводите style = "color: ###" в href, чтобы установить его так, как хотите, если вы хотите установить каждую отдельную ссылку. :)

Для более общего использования используйте

<a href="http://" class="red">RED</a>

<a href="http://" class="blue">RED</a>

и в вашем состоянии файла CSS

.red {
color: red;
}

.blue {
color: blue;
}
1
ответ дан Mantar 20 August 2018 в 17:05
поделиться

просто задайте имя класса для гипер гиперссылок <a> и напишите CSS в соответствии с требованиями ur

для примера

CSS

<style>
.red { 
 color : #f00; text-decoration : none;
}

.green { 
 color : #0f0; text-decoration : none;
}

.blue { 
 color : #00f; text-decoration : none;
}

</style>

Разметка:

<a href="#" class="red" > Link0 </a>
<a href="#" class="green" > Link1 </a>
<a href="#" class="blue" > Link2 </a>

Простая демонстрация

2
ответ дан user 20 August 2018 в 17:05
поделиться
  • 1
    Спасибо, это очень помогло. Тем не менее, новые классы не имеют некоторых эффектов, которые мне нужны, например, подчеркиваются, когда они зависнут. Как я могу расширить эти вещи CSS? – Spencer 25 December 2010 в 21:52