html - aligning custom LI svg images -


given following html (bootply here).

<div class="risk">     <ul>     <li><span>aggressive</span>lorem ipsum dolor ...</li>     <li><span>growth</span>doloremque autem...</li>     </ul> </div> 

with scss follows:

ul {     list-style: none;     margin: 0;     padding: 0;     li {         margin: 0;         padding: 0 0 0 40px;         span {             &:before {                 content: url('data:image/svg+xml;utf8,<svg width="24px" height="24px" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><rect x="1" y="1" rx="6" ry="6" width="22" height="22" style="fill:transparent;stroke:black;stroke-width:1.1;opacity:0.9" ></rect></svg>');                 display: inline-block;                 width: 30px;                 margin-left: -30px;             }             font-weight: bold;             margin-right: 2rem;         }     } } 

how svg line middle of li text.
have tried large number of padding, , margin options, image way higher text.

you need align icons @ middle other elements.

just add : vertical-align: middle;

css code

 div.risk ul {      list-style: none;      margin: 0;      padding: 0; }      div.risk ul li {        margin: 0;        padding: 0 0 0 40px; }        div.risk ul li span {          font-weight: bold;          margin-right: 2rem; }          div.risk ul li span:before {            content: url('data:image/svg+xml;utf8,<svg width="24px" height="24px" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><rect x="1" y="1" rx="6" ry="6" width="22" height="22" style="fill:transparent;stroke:black;stroke-width:1.1;opacity:0.9" ></rect></svg>');            display: inline-block;    			vertical-align: middle; /* line */            width: 30px;            margin-left: -30px; }
<div class="risk">  	<ul>      <li><span>aggressive</span>lorem ipsum dolor sit amet, consectetur adipisicing elit. suscipit quibusdam tempora numquam, officiis cupiditate libero maxime explicabo accusantium, deserunt voluptatem doloremque autem laborum eligendi magnam recusandae ab, perferendis impedit.</li>      <li><span>growth</span>lorem ipsum dolor sit amet, consectetur adipisicing elit. suscipit quibusdam tempora numquam, officiis cupiditate libero maxime explicabo accusantium, deserunt voluptatem doloremque autem laborum eligendi magnam recusandae ab, perferendis impedit.</li>      </ul>  </div>


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -