1 / 3 / 1
Регистрация: 26.05.2014
Сообщений: 59
|
|||||||||||
1 | |||||||||||
Обращение к значению кастомного атрибута CSS17.07.2015, 12:01. Показов 1962. Ответов 24
Метки нет (Все метки)
Доброго дня.
Есть следующая конструкция:
Пробовал вот такие варианты:
Каким образом можно обратиться к значению атрибута с символом двоеточия?
0
|
17.07.2015, 12:01 | |
Ответы с готовыми решениями:
24
Доступ к узлу XML файла по значению атрибута. Получения индекса узла по значению JavaFX подгрузка кастомного шрифта через css Выборка по значению атрибута data-* Поиск объекта в списке по значению атрибута |
413 / 378 / 220
Регистрация: 18.07.2014
Сообщений: 1,259
|
|
17.07.2015, 12:18 | 2 |
Interstellar,
https://jsfiddle.net/LwnwnLmf/ приведенный вами код с экранированием работает в
1
|
413 / 378 / 220
Регистрация: 18.07.2014
Сообщений: 1,259
|
|
17.07.2015, 12:45 | 4 |
0
|
0 / 11 / 4
Регистрация: 12.07.2015
Сообщений: 92
|
|
17.07.2015, 13:19 | 6 |
Не пиши имя класса, совпадающее с именем тэга html5. Нельзя так делать.
Далее, CSS3 не понимает что такое Если нужно очень точно применить стиль к конкретному тегу в конкретном месте. Выделяем именно тэг <section>, и именно с классом... пусть будет epubs, далее ищем только первый следующий, идущий непосредственно за тэгом <section> заголовок h1, и именно к нему применяем стиль. Код
section.epubs + h1 { color: green; } Код
section h1:first-child { color: green; Введи data-id. вводи любое англ. слово (одно) без пробелов, можно с тире. Это один из допустимых "атрибутов пользователя". Код
<section class="epub" data-id="...."> Код
section[data-id="...."] { color: green; } ^= - начитается с .... $= - заканчивается на .... *= - где-то в слове имеется .... И никаких пробелов не пиши. Добавлено через 7 минут Еще можно применить стиль непосредственно к h1 c классом .title. Вот так: Код
.title { color: green; } Добавлено через 2 минуты Вернее так: Код
section[data-id="...."] > h1 { color: green; }
1
|
1 / 3 / 1
Регистрация: 26.05.2014
Сообщений: 59
|
||||||
17.07.2015, 14:43 [ТС] | 7 | |||||
Действительно, в jsfiddle всё работает.
Но попробуйте запустить что-то вроде:
Это особенность проекта - используется xhtml (забыл указать в первом посте).
0
|
98 / 98 / 46
Регистрация: 21.03.2012
Сообщений: 378
|
|
17.07.2015, 16:01 | 9 |
0
|
1 / 3 / 1
Регистрация: 26.05.2014
Сообщений: 59
|
|
17.07.2015, 16:08 [ТС] | 11 |
На самом деле, это удивительно, что у вас работает данный код.
Вот тут автор описывает аналогичную проблему и указывает решение в замене epub:type на epub-type, т.к. пользовательские атрибуты с символом двоеточия из XML не работают в HTML/CSS. К сожалению, для меня такое решение неприемлемо, поэтому буду строить костыли.
0
|
98 / 98 / 46
Регистрация: 21.03.2012
Сообщений: 378
|
|
17.07.2015, 16:26 | 13 |
Fedor92, у вас на скрине файл сохранен в html :S
Добавлено через 7 минут вообщем валидацию не проходит на xhtml 1.1 Кликните здесь для просмотра всего текста
DOCTYPE Override in effect!
The DOCTYPE Declaration for "XHTML 1.1" has been inserted at the start of the document, but even if no errors are shown below the document will not be Valid until you add the new DOCTYPE Declaration. Info No Character encoding declared at document level No character encoding information was found within the document, either in an HTML meta element or an XML declaration. It is often recommended to declare the character encoding in the document itself, especially if there is a chance that the document will be read from or saved to disk, CD, etc. See this tutorial on character encoding for techniques and explanations. ↑ TOP Validation Output: 4 Errors Error Line 14, Column 11: end tag for "head" which is not finished </head> ✉ Most likely, you nested tags and closed them in the wrong order. For example <p><em>...</p> is not acceptable, as <em> must be closed before <p>. Acceptable nesting is: <p><em>...</em></p> Another possibility is that you used an element which requires a child element that you did not include. Hence the parent element is "not finished", not complete. For instance, in HTML the <head> element must contain a <title> child element, lists require appropriate list items (<ul> and <ol> require <li>; <dl> requires <dt> and <dd>), and so on. Error Line 16, Column 24: there is no attribute "class" <section class="section" epub:type="subchapter"> ✉ You have used the attribute named above in your document, but the document type you are using does not support that attribute for this element. This error is often caused by incorrect use of the "Strict" document type with a document that uses frames (e.g. you must use the "Transitional" document type to get the "target" attribute), or by using vendor proprietary extensions such as "marginheight" (this is usually fixed by using CSS to achieve the desired effect instead). This error may also result if the element itself is not supported in the document type you are using, as an undefined element will have no supported attributes; in this case, see the element-undefined error message for further information. How to fix: check the spelling and case of the element and attribute, (Remember XHTML is all lower-case) and/or check that they are both allowed in the chosen document type, and/or use CSS instead of this attribute. If you received this error when using the <embed> element to incorporate flash media in a Web page, see the FAQ item on valid flash. Error Line 16, Column 44: there is no attribute "epub:type" <section class="section" epub:type="subchapter"> ✉ You have used the attribute named above in your document, but the document type you are using does not support that attribute for this element. This error is often caused by incorrect use of the "Strict" document type with a document that uses frames (e.g. you must use the "Transitional" document type to get the "target" attribute), or by using vendor proprietary extensions such as "marginheight" (this is usually fixed by using CSS to achieve the desired effect instead). This error may also result if the element itself is not supported in the document type you are using, as an undefined element will have no supported attributes; in this case, see the element-undefined error message for further information. How to fix: check the spelling and case of the element and attribute, (Remember XHTML is all lower-case) and/or check that they are both allowed in the chosen document type, and/or use CSS instead of this attribute. If you received this error when using the <embed> element to incorporate flash media in a Web page, see the FAQ item on valid flash. Error Line 16, Column 56: element "section" undefined <section class="section" epub:type="subchapter"> ✉ You have used the element named above in your document, but the document type you are using does not define an element of that name. This error is often caused by: incorrect use of the "Strict" document type with a document that uses frames (e.g. you must use the "Frameset" document type to get the "<frameset>" element), by using vendor proprietary extensions such as "<spacer>" or "<marquee>" (this is usually fixed by using CSS to achieve the desired effect instead). by using upper-case tags in XHTML (in XHTML attributes and elements must be all lower-case).
1
|
1 / 3 / 1
Регистрация: 26.05.2014
Сообщений: 59
|
|
17.07.2015, 16:29 [ТС] | 14 |
0
|
Fourd
|
17.07.2015, 16:44
#17
|
0
|
1 / 3 / 1
Регистрация: 26.05.2014
Сообщений: 59
|
|
17.07.2015, 16:48 [ТС] | 18 |
Содержимое XHTML страниц в моём проекте формируется трансформациями из чистого XML, затем стилизуется с помощью CSS. Так как я сам до конца в них (трансформациях) не разобрался, а время поджимает, то разумно поставить небольшой костыль с заметкой о необходимости исправления на будущее.
0
|
17.07.2015, 16:57 | 19 |
Fourd, дело в том, что section годится для xhtml, но фишка в самом селекторе, как все уже поняли... Можно указать свойства внутренним стилем и они будут применяться... Можно задать для section class="item" и через него задать свойства всем элементам внутри... Можно тупо убрать epub у type и тупо задать свойства... Надо немного покопать и я думаю можно будет найти рациональный способ для задания свойств через селектор атрибута - это лишь дело времени...
0
|
Fourd
|
17.07.2015, 17:27
Обращение к значению кастомного атрибута CSS
#20
|
Не по теме: Fedor92, я не понял, пока не написали... мало опыта сказывается =(
0
|
17.07.2015, 17:27 | |
Вывести данные по значению атрибута xml Вывод xml нодов по значению атрибута Поиск XML-файла по значению атрибута Ограничение ввода данных по значению атрибута Выборка элементов XElement по имени и значению атрибута Найти XML элемент по значению атрибута и изменить другие атрибуты Искать еще темы с ответами Или воспользуйтесь поиском по форуму: |