Almost perfect solution, that automatically scales to dimensions of an element would be usage of CSS3 linear-gradient connected with calc() as shown below. Main drawback is of course compatibility. Code below works in Firefox 25 and Explorer 10 and 11, but in Chrome (I've tested v30 and v32 dev) there are some subtle problems with lines disappearing if they are too narrow. Moreover disappearing depends on the box dimensions – style below works for div { width: 100px; height: 100px}
, but fails for div { width: 200px; height: 200px}
for which in my tests 0.8px
in calculations needs to be replaced with at least 1.1048507095px
for diagonals to be shown and even then line rendering quality is quite poor. Let's hope this Chrome bug will be solved soon.
.crossed {_x000D_
background: _x000D_
linear-gradient(to top left,_x000D_
rgba(0,0,0,0) 0%,_x000D_
rgba(0,0,0,0) calc(50% - 0.8px),_x000D_
rgba(0,0,0,1) 50%,_x000D_
rgba(0,0,0,0) calc(50% + 0.8px),_x000D_
rgba(0,0,0,0) 100%),_x000D_
linear-gradient(to top right,_x000D_
rgba(0,0,0,0) 0%,_x000D_
rgba(0,0,0,0) calc(50% - 0.8px),_x000D_
rgba(0,0,0,1) 50%,_x000D_
rgba(0,0,0,0) calc(50% + 0.8px),_x000D_
rgba(0,0,0,0) 100%);_x000D_
}
_x000D_
<textarea class="crossed"></textarea>
_x000D_