-5
我在C#
後面創建了以下div,但無法在屏幕的center
中使用position
。任何人都有合適的答案是值得讚賞的要做到這一點如何居中絕對定位動態創建div
<div class="rect" style="top:" + (rectangles.ElementAt(i).Y + 50).ToString() + "px;left:" + (rectangles.ElementAt(i).X + 50).ToString() + "px;width:" + (rectangles.ElementAt(i).Width - 1).ToString() + "px;height:" + (rectangles.ElementAt(i).Height - 1).ToString() + "px;border-color:Black;text-shadow:3px 3px Black;border-width:3px;border-style:solid;border-collapse:seperate;position:absolute;background-color:#" + rectangles.ElementAt(i).Slice.Elements.ElementAt(0).color.ToString() + ";vertical-align:middle;text-align:center;font-family:Arial;font-size:48px;color:White;font-weight:bold;display:table-cell;" ><div style="position: relative;top: 50%;transform: translateY(-50%);"><span>" + rectangles.ElementAt(i).Slice.Elements.ElementAt(0).Symbol + "</span><br/><span>" + rectangles.ElementAt(i).Slice.Elements.ElementAt(0).AverageMC + "%</span></div></div>
只有這個代碼將不會幫助..'提供more' – Moumit
可能的複製[如何中心與位置絕對動態創建一個div(HTTP ://stackoverflow.com/questions/35696003/how-to-center-a-div-created-dynamically-with-position-absolute) –