CSS list-style-image size

后端 未结 11 1421
离开以前
离开以前 2020-12-02 10:24

I\'m trying to set custom SVG icons with CSS on a

    \'s list items. Example:

11条回答
  •  半阙折子戏
    2020-12-02 10:56

    I did a kind of terminal emulator with Bootstrap and Javascript because I needed some dynamic to add easily new items, and I put the prompt from Javascript.

    HTML:

      
    Comandos SQL ejecutados

      Javascript:

      function addCommand(command){
          //Creating the li tag   
          var li = document.createElement('li');
          //Creating  the img tag
          var prompt = document.createElement('img');
          //Setting the image 
          prompt.setAttribute('src','./lib/custom/img/terminal-prompt-white.png');
          //Setting the width (like the font)
          prompt.setAttribute('width','15px');
          //Setting height as auto
          prompt.setAttribute('height','auto');
          //Adding the prompt to the list item
          li.appendChild(prompt);
          //Creating a span tag to add the command
          //li.appendChild('el comando');   por que no es un nodo
          var span = document.createElement('span');
          //Adding the text to the span tag
          span.innerHTML = command;
          //Adding the span to the list item
          li.appendChild(span);
          //At the end, adding the list item to the list (ul)
          document.getElementById('ulCommand').appendChild(li);
      }
      

      CSS:

      .panel-terminal-body {
        background-color: #423F3F;
        color: #EDEDED;
        padding-left: 50px;
        padding-right: 50px;
        padding-top: 15px;
        padding-bottom: 15px;
        height: 300px;
      }
      
      .panel-terminal-body ul {
        list-style: none;
      }
      

      I hope this help you.

    提交回复
    热议问题