我寫了jsfiddle example以便更好的解釋,那麼,如何讓紅色條紋填充整個高度.frame
?也許有什麼更好的辦法來製造這樣的事情嗎?帶有書籤式樣的文字div
0
A
回答
0
我自己解決。 JSfiddle demo。
var move_bookmark = function(){
var sh = parseInt($(this).css('height').replace('px',''));
var ph = parseInt($(this).parent().css('height').replace('px',''));
if (sh%2==0)//this is for solving [this problem] -
//http://math.stackexchange.com/questions/183018/pixel-rectangle-precise-rotating
{
if(ph%2!=0)
{
ph++;
$(this).parent().css('height',ph+'px');
}
}
else
{
if(ph%2==0)
{
ph++;
$(this).parent().css('height',ph+'px');
}
}
$(this).css('width',ph+'px');
var sw = ph;
var offset = parseInt(ph-sw/2-sh/2)+'px'
console.log(sw+"/"+sh);
$(this).css('top',offset);
$(this).css('left',-sw/2+sh/2+'px');
$(this).parent().css('padding','0px 0px 0px '+sh+'px');
}
$('.bookmark').each(move_bookmark);
+0
@Thor完成。然後在jsfiddle上添加事件更好的代碼。 – scythargon 2012-08-16 11:21:08
1
定位元素不再是佈局的一部分,因此他們不知道父元素的尺寸是什麼。你需要使用JavaScript來做到這一點。
相關問題
- 1. word vba在帶有樣式的書籤上插入文本
- 2. docx4j - 用文字和樣式替換書籤
- 3. 單擊,搜索書籤並顯示書籤所在的div div
- 4. AngularJs - 帶有角度的書籤按鈕
- 5. Golang - 帶有自簽名證書的TLS
- 6. CSS:帶有十字標籤和水平標籤的div
- 7. 帶有樣式的AJAX打印文本
- 8. 帶Div格式的Zurb-Foundation標籤
- 9. 定義Div標籤的樣式
- 10. 帶有垂直文字的Twitter標籤
- 11. 刪除帶有文字的HTML標籤
- 12. 展開帶有動畫的div容器,其中帶有文字
- 13. 帶文字的線條樣式右側的文字
- 14. 如何在contenteditable div上書寫任何帶有圖釋的文字
- 15. 如何找到帶有樣式的div元素?
- 16. 解析netscape樣式書籤html文件嵌套數組
- 17. 帶有書籤頁的元標籤「width = device-width」錯誤
- 18. 從div標籤中刪除樣式css
- 19. cfchart帶有數據的餅圖標籤樣式
- 20. 在帶有javascript的標籤中應用樣式(不包括jQuery)
- 21. XCode - 添加一個帶有標籤樣式的按鈕?
- 22. 帶有關聯標籤控件的樣式單選按鈕
- 23. 創建書籤如果div包含某些文字
- 24. 字數書籤
- 25. 帶div標籤的TinyMCE?
- 26. 如何從XML文件中刪除具有樣式屬性的DIV標籤?
- 27. 當輸入有文字時更改標籤樣式
- 28. 使用VBA填充帶有文本的div標籤
- 29. ggplot2帶文字標籤facet_wrap
- 30. 帶有WrapPanel的ListView的選擇樣式
輪換變得更加困難,但也許該相同高度的方法可以幫助:http://matthewjamestaylor.com/blog/equal-height-columns-cross-browser-css-no-hacks – 2012-08-15 20:08:11
@SebastianG哇,很酷的文章和漂亮的博客:)我會考慮如何將這個應用於我的問題... – scythargon 2012-08-15 20:50:26