Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to avoid line break of HTML-Elements within a parent-span?

I want to put two HTML elements next to each other and avoid that the second element (icon) will start in the next line. They shall always be rendered next to each other by all means.

Code:

   <span class="white-space:nowrap;display:inline-block;overflow: 
   hidden;">
       <span class="ui darkgray label" style="font-family: Courier New, Monospace">0x1fc...cc75</span>
       <a href="https://rinkeby.etherscan.io/address/xxxxxx" 
   target="_blank" style="color: black" title="Lookup on Block-Explorer">
          <i class="eye icon"></i>
       </a>
    </span>

Explanation: the inner and the element shall be rendered next to each other instead of getting rendered line by line.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

What happens within smaller browser windows, is this:

enter image description here

What I want to achieve instead:

enter image description here

How to do that?

I read about white-space: nowrap but this is never recognized.
I read also about display:inline-block;overflow: hidden but it all doesnt matter. Browsers are not recognizing anything of these styles.

>Solution :

white-space is used for text wrap, more about white-space
Use flexbox, more about flexbox.

div {
  display: flex;
  flex-wrap: nowrap;
}

span {
  height: 40px;
  border-radius: 4px;
  color: #ffffff;
}

.one {
  width: 200px;
  background-color: red;
  margin-right: 5px;
}

.two {
  width: 40px;
  background-color: blue;
}
<div>
  <span class="one">1</span>
  <span class="two">2</span>
</div>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading