[css] 페이지가 자바 스크립트 지원없이로드 될 때 텍스트 상자에 커서 (자동 초점)를 배치하는 방법은 무엇입니까?

일부 텍스트 필드가있는 양식이 있고 페이지가로드 될 때 양식의 첫 번째 텍스트 필드에 커서 (자동 초점) 를 놓고 싶습니다 .

자바 스크립트를 사용하지 않고하고 싶습니다.



답변

javascript의 지원 없이도 가능합니다.
html5 자동 초점 속성을 사용할 수 있습니다
. 예 :

<input type="text" name="name" autofocus="autofocus" id="xax" />

텍스트 필드에서 사용하면 (autofocus = “autofocus”) 페이지가로드 될 때 텍스트 필드에 초점이 맞춰진다는 의미입니다. 자세한 내용은 다음을 참조 하십시오.
http://www.hscripts.com/tutorials/html5/autofocus-attribute.html


답변

autofocus첫 번째 입력 또는 텍스트 영역을 추가하기 만하면 됩니다.

<input type="text" name="name" id="xax" autofocus="autofocus" />


답변

이것은 작동합니다 :

OnLoad="document.myform.mytextfield.focus();"


답변

<body onLoad="self.focus();document.formname.name.focus()" >

formname is <form action="xxx.php" method="POST" name="formname" >
and name is <input type="text" tabindex="1" name="name" />

it works for me, checked using IE and mozilla.
autofocus, somehow didn't work for me.


답변

내가 한 것처럼 약간의 장난을 치는 사람들을위한 확장팩입니다.

다음 작업 (W3에서) :

<input type="text" autofocus />
<input type="text" autofocus="" />
<input type="text" autofocus="autofocus" />
<input type="text" autofocus="AuToFoCuS" />

이것은 CSS에서는 작동하지 않는다는 점에 유의하는 것이 중요합니다. 즉 다음을 사용할 수 없습니다.

.first-input {
    autofocus:"autofocus"
}

적어도 그것은 나를 위해 작동하지 않았습니다 …


답변

때때로 커서가 텍스트 상자 안에 있는지 확인하기 위해해야 ​​할 일은 텍스트 상자를 클릭하고 메뉴가 표시되면 “텍스트 상자 서식”을 클릭 한 다음 “텍스트 상자”탭을 클릭하고 마지막으로 모두 수정하는 것입니다. 각 여백에 “0”이 나타날 때까지 아래쪽 화살표로 4 개의 여백 (왼쪽, 오른쪽, 위쪽 및 아래쪽).


답변