Home > Mobile >  Can I use Django in a way that I can change CSS variables?
Can I use Django in a way that I can change CSS variables?

Time:10-27

I am creating a personal website and I have a progress bar that has been done in css and html.

in order to control the progress bars all I need to do is change a variable(width). This is the code for one bar:

.bar-inner1 {
  width: 559px;
  height: 35px;
  line-height: 35px;
  background: #db3a34;
  border-radius: 5px 0 0 5px;
}

This is the corresponding html that is affected by this css:

<div >
  <h2 >My Skills</h2>
  <div >
  <div >HTML5</div>
  <div  data-width="65%">
    <div >

    </div>
    <div >65%</div>
  </div>
  </div>

How would I use Django to change the variable width?

I have looked through documentation and tutorials but I cannot seem to work it out.

CodePudding user response:

You can use inline CSS for that. Just use in inline css same you use in HTML.

CodePudding user response:

You can use Django to generate the initial width of the progress bar, using Context data and Template logic, but once the page is sent to the client Django can't influence it anymore..
You'd have to use Javascript/Jquery and if you really need some value from Django you'd ping the server with Ajax or refresh the page.

  • Related