0

Hi I used this code to draw 12 lines, but now I want to use for loop and to call in CSS, please tell me how to use.

    <!DOCTYPE html>
<html>
<head>

<style>

#straight{
height: 30px;
border-right: 1px solid blue; 
-webkit-transform: rotate(deg);
transform: rotate(deg); 
position: absolute;
top:40px;
left:400px;
}





#circle {
  height: 30px;
  width: 31px;
  margin-left: 81px;
  margin-top: 0px;
  background-color: #fff;
  border: 2px solid blue;
  border-radius: 65px;
  position:absolute;

}





</style>

</head>

<body>



                    <div>

                        <div id="circle">                       
                             <div style="position:relative; top:-40px; left:-385px;">
                                <div id="straight"></div>

                         </div>
                    </div>




</body>
</html>
0

2 Answers 2

1

Change the id to class

CSS:

.straight {
    height: 30px;
    border-right: 1px solid blue; 
    -webkit-transform: rotate(deg);
    transform: rotate(deg); 
    position: absolute;
    top:40px;
    left:400px;
}

Javascript:

for (var i = 0; i < 12; i++) {
    document.write('<hr class="straight" />');
}
Sign up to request clarification or add additional context in comments.

Comments

1

css

.straight {
        height: 30px;
        border-right: 1px solid blue; 
        -webkit-transform: rotate(deg);
        transform: rotate(deg); 
        position: absolute;
        top:40px;
        left:400px;
    }

javascript

var str_div = '';
for (var i = 0; i < 12; i++) {
    str_div += '<div class="straight" >test</div>';
}
document.getElementById("idName").innerHTML = str_div;

in html body

<div id="idName"></div>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.