Как Вы устанавливаете переключатель в css?

Line 1:String x = new String("xyz");
Line 2:String y = "abc";
Line 3:x = x + y;

Строки являются неизменяемыми, поэтому, если необходимо изменить существующую строковую переменную, для назначения будет создан новый объект. Строка 1, строка 2 являются строковыми объектами, где строка 3 является модификацией существующей строковой переменной, поэтому необходимо добавить новое распределение для добавления x + y. Таким образом, он должен создать создает 3 объекта.

39
задан Brettski 16 June 2009 в 16:26
поделиться

6 ответов

input[type="radio"] is an example of an attribute selector. It's part of the CSS3 spec and is perfectly legal. The only browser that doesn't support them is IE6. If supporting IE6 is important to the project, then you should look into adding classes to the radio buttons in question.

Here's an article with an example of how to effectively use attribute selectors. Check out this article for more info on CSS3 goodies.

64
ответ дан 27 November 2019 в 02:30
поделиться

The attribute selector (input[type="radio"]) is the correct solution, widely supported by everything but IE6 :)

If you have no ability to modify the HTML to inject classname support (or access to javascript to accomplish this) then your options are:

A). to make sure your site doesn't depend on this, and allow IE6 to degrade gracefully.

B). live without it

9
ответ дан 27 November 2019 в 02:30
поделиться

you could use jQuery to select the input and add a class dynamically.

Example (source: http://docs.jquery.com/Attributes/addClass#class):

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
                    "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
  <script src="http://code.jquery.com/jquery-latest.js"></script>

  <script>
  $(document).ready(function(){
    $("p:last").addClass("selected highlight");
  });
  </script>
  <style>
  p { margin: 8px; font-size:16px; }
  .selected { color:red; }
  .highlight { background:yellow; }
  </style>
</head>
<body>
  <p>Hello</p>
  <p>and</p>
  <p>Goodbye</p>
</body>
</html>

[Edit]

an alternative to jQuery is to use http://code.google.com/p/ie7-js/

it fixes loads of issues with ie versions lower than 7 the fix that will interest you most is illustrated here:

http://ie7-js.googlecode.com/svn/test/attr-value.html

4
ответ дан 27 November 2019 в 02:30
поделиться

The one you mention above is the correct way to target it by CSS. It's called an attribute selector. It is not supported by IE6 and below however. They can be simulated by adding a conditional behaviour script for IE6. (Just search on google, the file ending is usually .htc).

It should probably be noted that .htc-files usually result in horrendous performance and should only be used sparingly and be thoroughly tested to ensure that the performance hit is acceptable.

1
ответ дан 27 November 2019 в 02:30
поделиться

Your solution is the correct one and will work in all modern browsers apart from IE6. For IE6 you'll have to either find way of selecting them, modify the HTML or use Javascript.

0
ответ дан 27 November 2019 в 02:30
поделиться

You could use jQuery to find all the radio buttons on the page, then add some CSS classes to it.

0
ответ дан 27 November 2019 в 02:30
поделиться
Другие вопросы по тегам:

Похожие вопросы: