css onclick div

相關問題 & 資訊整理

css onclick div

I had a similar situation, I needed a popup div with onClick where I couldn't add any JS or change the markup/HTML (a truly CSS solution) and this is possible with some caveats. You can't use the :target trick that can create a nice popup unless , CSS does not have an onlclick event handler. You have to use Javascript. See more info here on CSS Pseudo-classes: http://www.w3schools.com/css/css_pseudo_classes.asp a:link color:#FF0000;} /* unvisited link - link is untouched */ a:visited color:#00FF00, Depends in how you are hiding your div, diplay=none is different of visibility=hidden and the opacity=0. Visibility then use ...style.visibility='visible' Display then use ...style.display='block' (or others depends how you setup ur css, , Firstly, using on* attributes to add event handlers is a very outdated way of achieving what you want. As you've tagged your question with jQuery, here's a jQuery implementation: <div id="foo">hello world!</div> <img src=, Make your DIVs focusable, by adding tabIndex: <div tabindex="1"> Section 1 </div> <div tabindex="2"> Section 2 </div> <div tabindex="3"> Section 3 </div>. Then you can simple use :focus ps, If you renege on your question's premise that you need to avoid javascript, as others have pointed our you can use the onClick event handler. jQuery ... CSS: #my-div background-color: #f00; width: 200px; height: 200px; } a.fill-div display: block; , <div style="cursor: pointer;" onclick="theFunction()">. is the simplest thing that works. Of course in the final solution you should separate the markup from styling (css) and behavior (javascript) - read on it on a list apart f, You can put links inside of a DIV, of course, but sometimes you just want the whole DIV to be clickable as a link. No problem, here is how it's done: <div onclick="location.href='YOUR-URL-HERE';" style="cursor: pointer;", click anywhere. Rerun. It is best practice to cover all of the "states", particularly for links. An easy way to do that is "LOVE HATE" or. L :link. O V :visited. E. H :hover. A :active. T E. Doing them in that order is ideal. a:link , 舉例來說,最常見的特效就是當滑鼠移過去的時候,可以換個底圖或改變字的顏色,我們來瞧瞧CSS 怎麼辦到的吧: ... 1. 2. 3. <div class="sample">. sample. </div> ... 好的~香蕉現在就來告訴人客,click event 並沒有辦法靠CSS 單槍匹馬,扑克牌制作 這時候真的就需要JS 協助了,只需要少少的幾行JS 就可以了~.

相關軟體 Axialis IconWorkshop 資訊

Axialis IconWorkshop
用 Axialis IconWorkshop 為 Windows,MacOS 和 Unix 製作自己的圖標。為 Windows Vista / 7 創建 Windows 圖標高達 256x256,為 OSX Lion 10.7 創建最高為 1024x1024 的 Macintosh 圖標。 Unix / Linux 使用 PNG 圖標。 IconWorkshop 使用 alpha 通道創建 PNG... Axialis IconWorkshop 軟體介紹

css onclick div 相關參考資料
Can I have an onclick effect in CSS? - Stack Overflow

I had a similar situation, I needed a popup div with onClick where I couldn&#39;t add any JS or change the markup/HTML (a truly CSS solution) and this is possible with some caveats. You can&#39;t use...

https://stackoverflow.com

Show hide div on click with CSS - Stack Overflow

CSS does not have an onlclick event handler. You have to use Javascript. See more info here on CSS Pseudo-classes: http://www.w3schools.com/css/css_pseudo_classes.asp a:link color:#FF0000;} /* unvisi...

https://stackoverflow.com

javascript - Adding an onclick event to a div element - Stack Overflow

Depends in how you are hiding your div, diplay=none is different of visibility=hidden and the opacity=0. Visibility then use ...style.visibility=&#39;visible&#39; Display then use ...style.display=&#...

https://stackoverflow.com

javascript - Change CSS properties on click - Stack Overflow

Firstly, using on* attributes to add event handlers is a very outdated way of achieving what you want. As you&#39;ve tagged your question with jQuery, here&#39;s a jQuery implementation: &lt;div id=&...

https://stackoverflow.com

html - Change div background color on click using only css - Stack ...

Make your DIVs focusable, by adding tabIndex: &lt;div tabindex=&quot;1&quot;&gt; Section 1 &lt;/div&gt; &lt;div tabindex=&quot;2&quot;&gt; Section 2 &lt;/div&gt; &lt;div tabindex=&quot;3&quot;&gt; Se...

https://stackoverflow.com

How to make a whole &#39;div&#39; clickable in html and css without ...

If you renege on your question&#39;s premise that you need to avoid javascript, as others have pointed our you can use the onClick event handler. jQuery ... CSS: #my-div background-color: #f00; widt...

https://stackoverflow.com

javascript - how to make div click-able? - Stack Overflow

&lt;div style=&quot;cursor: pointer;&quot; onclick=&quot;theFunction()&quot;&gt;. is the simplest thing that works. Of course in the final solution you should separate the markup from styling (css) a...

https://stackoverflow.com

Creating Clickable DIVs | CSS-Tricks

You can put links inside of a DIV, of course, but sometimes you just want the whole DIV to be clickable as a link. No problem, here is how it&#39;s done: &lt;div onclick=&quot;location.href=&#39;YOUR...

https://css-tricks.com

:active | CSS-Tricks

click anywhere. Rerun. It is best practice to cover all of the &quot;states&quot;, particularly for links. An easy way to do that is &quot;LOVE HATE&quot; or. L :link. O V :visited. E. H :hover. A :a...

https://css-tricks.com

沒想到CSS 也做的到?! | Mozilla Tech | 謀智台客

舉例來說,最常見的特效就是當滑鼠移過去的時候,可以換個底圖或改變字的顏色,我們來瞧瞧CSS 怎麼辦到的吧: ... 1. 2. 3. &lt;div class=&quot;sample&quot;&gt;. sample. &lt;/div&gt; ... 好的~香蕉現在就來告訴人客,click event 並沒有辦法靠CSS 單槍匹馬,扑克牌制作 這時候真的就需要JS 協助了,只需要少少的幾...

http://tech.mozilla.com.tw