Programing

Bootstrap 3에서 SR 전용이란 무엇입니까?

crosscheck 2020. 9. 30. 08:43
반응형

Bootstrap 3에서 SR 전용이란 무엇입니까?


수업은 무엇에 sr-only사용됩니까? 중요합니까 아니면 제거 할 수 있습니까? 없이 잘 작동합니다.

내 예는 다음과 같습니다.

<div class="btn-group">
    <button type="button" class="btn btn-info btn-md">Departments</button>
    <button type="button" class="btn btn-info dropdown-toggle btn-md" data-toggle="dropdown">
    <span class="caret"></span>
    <span class="sr-only">Toggle Dropdown</span>
    </button>
    <ul class="dropdown-menu" role="menu">
        <li><a href="#">Sales</a></li>
        <li><a href="#">Technical</a></li>
        <li class="divider"></li>
        <li><a href="#">Show all</a></li>
    </ul>
</div>

부트 스트랩 문서 에 따르면 이 클래스는 렌더링 된 페이지의 레이아웃에서 화면 판독기 전용 정보를 숨기는 데 사용됩니다 .

모든 입력에 대한 레이블을 포함하지 않으면 화면 판독기가 양식에 문제가 있습니다. 이러한 인라인 양식의 경우 .sr 전용 클래스를 사용하여 레이블을 숨길 수 있습니다.

다음은 사용 된 스타일링 예입니다 .

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  border: 0;
}

중요합니까 아니면 제거 할 수 있습니까? 없이 잘 작동합니다.

중요합니다. 제거하지 마십시오.

접근성을 위해 항상 화면 판독기를 고려해야합니다. 클래스를 사용하면 어쨌든 요소가 숨겨 지므로 시각적 차이를 볼 수 없습니다.

접근성에 대해 읽고 싶다면 :


JoshC가 말했듯이이 클래스는 화면 판독기에 사용되는 정보를 숨기는 데 사용됩니다. 그러나 레이블을 숨기는 것뿐만 아니라 복잡한 탐색이 있거나 콘텐츠 앞에 페이지 머리글을 추가하는 경우 시각 장애인에게 바람직한 내부 링크 "기본 콘텐츠로 건너 뛰기"를 숨길 수 있습니다. 화면 판독기로 접근하려면 아래쪽 화살표 키를 너무 많이 눌러야합니다.

사이트가 스크린 리더와 더 많이 상호 작용하도록하려면 W3C 표준화 된 ARIA 속성을 사용 하세요. Google 온라인 과정 을 방문하는 것이 좋습니다.이 과정 은 최대 1 ~ 2 시간 정도 걸리거나 적어도 Google의 40 분 동영상을 시청하는 것이 좋습니다 .

세계 보건기구 (WHO)에 따르면 2 억 8500 만 명의 사람들이 시각 장애가 있습니다. 따라서 웹 사이트를 액세스 가능하게 만드는 것이 중요합니다.


navbar 예제 에서 이것을 발견 하고 단순화했습니다.

<ul class="nav">
  <li><a>Default</a></li>
  <li><a>Static top</a></li>
  <li><b><a>Fixed top <span class="sr-only">(current)</span></a></b></li>
</ul>

어느 것이 선택되었는지 확인합니다 ( sr-only부분이 숨겨 짐).

  • 기본
  • 정적 상단
  • 고정 상단

화면 판독기를 사용하는 경우 어느 것이 선택되었는지 들립니다.

  • 기본
  • 정적 상단
  • 고정 상단 (현재)

이 기술의 결과로 시각 장애인은 웹 사이트에서 더 쉽게 탐색해야합니다.


.sr-only is a class name specifically used for screen readers. You can use any class name, but .sr-only is pretty commonly used. If you don't care about developing with compliance in mind, then it can be removed. It will not affect UI in any way if removed because the CSS for this class is not visible to desktop and mobile device browsers.

There seems to be some information missing here about the use of .sr-only to explain its purpose and being for screen readers. First and foremost, it is very important to always keep impaired users in mind. Impairment is the purpose of 508 compliance: https://www.section508.gov/, and it is great that bootstrap takes this into consideration. However, the use of .sr-only is not all that needs to be taken into consideration for 508 compliance. You have the use of color, size of fonts, accessibility via navigation, descriptors, use of aria and so much more.

But as for .sr-only - what does the CSS actually do? There are several slightly different variants of the CSS used for .sr-only. One of the few I use is below:

.sr-only {
    position: absolute;
    margin: -1px 0 0 -1px;
    padding: 0;
    display: block;
    width: 1px;
    height: 1px;
    font-size: 1px;
    line-height: 1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    border: 0;
    outline: 0;
    }

The above CSS hides content in desktop and mobile browsers wrapped with this class, but is seen by a screen reader like JAWS: http://www.freedomscientific.com/Products/Blindness/JAWS. Example markup is as follows:

<a href="#" target="_blank">
    Click to Open Site
    <span class="sr-only">This is an external link</span>
</a>

Additionally, if a DOM element has a width and height of 0, the element is not seen by the DOM. This is why the above CSS uses width: 1px; height: 1px;. By using display: none and setting your CSS to height: 0 and width: 0, the element is not seen by the DOM and is thus problematic. The above CSS using width: 1px; height: 1px; is not all you do to make the content invisible to desktop and mobile browsers (without overflow: hidden, your content would still show on the screen), and visible to screen readers. Hiding the content from desktop and mobile browsers is done by adding an offset from width: 1px and height: 1px previously mentioned by using:

position: absolute;
margin: -1px 0 0 -1px; 
overflow: hidden;

Lastly, to have a very good idea of what a screen reader sees and relays to its impaired user, turn off page styling for your browser. For Firefox, you can do this by going to:

View > Page Style > No Style

I hope the information I provided here is of further use to someone in addition to the other responses.


Ensures that the object is displayed (or should be) only to readers and similar devices. It give more sense in context with other element with attribute aria-hidden="true".

<div class="alert alert-danger" role="alert">
  <span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span>
  <span class="sr-only">Error:</span>
  Enter a valid email address
</div>

Glyphicon will be displayed on all other devices, word Error: on text readers.


The .sr-only class hides an element to all devices except screen readers:

Skip to main content Combine .sr-only with .sr-only-focusable to show the element again when it is focused

참고URL : https://stackoverflow.com/questions/19758598/what-is-sr-only-in-bootstrap-3

반응형