EricTalv
EricTalv

Reputation: 1049

Setting an element next to another element

I have list which takes up 100% of height room next to which I am trying to set an image box

fiddle: https://jsfiddle.net/wrdvkgyj/

I got close by setting my image container to inline yet the picture seems to be pushed out again, im unsure whats going wrong here..

HTML:

<div id="wrapper">
  <div class="project-list">
                         <ul>
                            <li>item1</li>
                            <li>item2</li>
                            <li>item3</li>
                            <li>item4</li>  
                         </ul>
  </div>
  <div id="image-container">
     <div class="image-holder">
       <img src="https://semantic-ui.com/images/wireframe/image.png">
     </div>
  </div>
  <div class="description-container"></div>
</div>

CSS:

/* wrapper  */
html, body {
  width: 100%;
  height: 100%;
}

#wrapper {
  width: 100%;
  height: 100%;
  border: 1px solid black;
}

/* project list  */
.project-list  {  
  border: 1px solid #cccc;
  float: left;
  font-size: 25px;
  width: 30%;
  height: 100%;
  overflow-x: hidden;
}

.project-list ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.project-list li {
  float: left;
  clear: left;
  width: 100%;
  padding: 10px;
  transition: all .3s ease;
}

.project-list li:nth-child(even){
    background-color: #f8f8f8;
}

/*li-hover*/
.project-list li:hover {
  color: red;
  background-color: #d8d8d8;
  cursor: pointer;
}

Upvotes: 1

Views: 33

Answers (1)

Friday Ameh
Friday Ameh

Reputation: 1684

You did everything right just change the width of your #image-container to 0. and add box-sizing: border-box; to your css. Hope this help

*{
  box-sizing: border-box;
}

html, body {
  width: 100%;
  height: 100%;
}

#wrapper {
  width: 100%;
  height: 100%;
  border: 1px solid black;
  box-sizing: border-box;
}

/* project list  */
.project-list  {
  border: 1px solid #cccc;
  float: left;
  font-size: 25px;
  width: 30%;
  height: 100%;
  overflow-x: hidden;
}

.project-list ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.project-list li {
  float: left;
  clear: left;
  width: 100%;
  padding: 10px;
  transition: all .3s ease;
}

.project-list li:nth-child(even){
    background-color: #f8f8f8;
}

/*li-hover*/
.project-list li:hover {
  color: red;
  background-color: #d8d8d8;
  cursor: pointer;
}

#image-container{
  width: 0;
}
<div id="wrapper">
  <div class="project-list">
                         <ul>
                            <li>item1</li>
                            <li>item2</li>
                            <li>item3</li>
                            <li>item4</li>
                         </ul>
  </div>
  <div id="image-container">
     <div class="image-holder">
       <img src="https://semantic-ui.com/images/wireframe/image.png">
     </div>
  </div>
  <div class="description-container"></div>
</div>

Upvotes: 1

Related Questions