Placing one element beside another element

I am facing an issue with my layout where I have a list taking up 100% of the height and next to it, I am attempting to place an image box.

Here is the fiddle link for reference: https://jsfiddle.net/wrdvkgyj/

Even after setting my image container to inline, the picture seems to be pushed out. I am unsure of what might be 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;
}

Answer №1

To correct the issue, simply adjust the width of your #image-container to 0 and include box-sizing: border-box; in your CSS. This should resolve the problem.

*{
  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>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

The information displayed in the tooltip exceeds the capacity of the column

Is there a way to display data in a tooltip when a column contains long sentences due to width constraints? To achieve this, I have implemented a renderer function as shown below: { header: xppo.st('SDE_INCIDENT_DESCRIPTION1'), width: 1 ...

Restricting the size of uploaded files in WebApi

Here is a simple WebApi code snippet that allows for file uploads: [HttpPost] public async Task<bool> UploadSingleFile() { bool isSuccess = false; try { var streamProvider = new MultipartFormDataStreamProvider("D:\\") ...

JavaScript Cookie Array Handling

Is it possible to create a 2D array as a cookie in JavaScript? If so, how can I go about creating this array cookie and looping through it to retrieve data efficiently? Any guidance on this would be greatly appreciated. Thank you! ...

Utilize CSS Steps to incorporate the initial position

I'm experimenting with CSS steps to create a unique visual effect resembling a "light board". The setup involves a column of 18 divs acting as individual "bulbs", with an animation that positions a div behind each one to simulate a "lit up bulb." The ...

R: Extracting data from web pages: The content appears to be formatted in XML but is not recognized as such; employing HTML

Working on scraping data from multiple years which are represented by different webpages. I have successfully extracted the 2019 data as expected, but encountering an error while attempting to preprocess the 2016 data in a similar manner. url19 <- &apos ...

Extracting multiline value from a textarea using JavaScript

I'm trying to extract a multiline value from a textarea using JavaScript or jQuery and store it in a cookie. Below is the code snippet I am using: HTML: <textarea id="cont" cols="72" rows="15"> JavaScript: var txt = $('#cont').val( ...

Achieving a layered effect with elements overlapping onto another div

Looking for a way to create a design where the text in id="text-field" overlaps with id="image-field". Need some guidance on how to achieve this effect. Any help is appreciated. <!DOCTYPE html> <html> <body> <div class=" ...

What is causing the "draggable='true'" attribute to fail on a React-rendered component?

This situation is really frustrating me, and I am hoping that someone can offer some assistance. I'm working with a React.Component that looks like this: var Vehicle = React.createClass({ ondragend: function(e) { e.preventDefault(); ...

Tips for including a footer element in React:How can a footer division be

I need help with implementing a footer in my React web app. Currently, the body section in index.html looks like this: <body> <div id="root"></div> <script src="index.js"></script> </body> Inside index.js, the rend ...

Error encountered during the construction of the dojo due to a CSS syntax

I am currently using version 1.9.3 of dojo, and I have encountered an issue with the css file when trying to build dojo using build.bat. The code in my css file is as follows: @import url("TimeDriverCommon.css"); @import url("DialogCommon.css"); @import ...

What is the best way to position the div element to the right side of the webpage?

Looking at my HTML code below, I am trying to reposition the 'site-logo' and 'nav-search-wrapper' div elements to the left side of the parent div (top-nav) and have the 'list' div element appear on the right side. However, the ...

Concealing forms within an Angular 5 application

I'm currently working on displaying the terms of use on the initial screen along with two buttons. If the user clicks the accept button, they will be directed to the authentication form. However, if they click refuse, the "Refused Terms" screen will a ...

Click event from Angular Material menu is triggered twice on mobile devices

After implementing a basic angular material side menu from the demo, I noticed that all click events are being fired twice on the entire page when viewed in mobile browsers. This issue can even be replicated in the Chrome emulator. (To reproduce, enable th ...

Emails sent through an HTML form submission should always include a valid "from"

I am currently in the process of creating a feedback form that allows individuals to provide anonymous feedback. I have explored nodemailer and node-sendmail, but I have encountered an issue with both requiring a from address. While I am aware that this ca ...

Images that have been resized on Android appear blurry when viewed on the second page

Customizing the Toolbar: #main_bar { background: url(../images/logo.jpg) 99% 50% no-repeat; background-size: auto 80%; } The original size of logo.jpg is 220x266px The toolbar has a fixed height of 46px Therefore, the background image appears t ...

Tips on adding to Jquery html code while maintaining the current CSS styling

My JavaScript function looks like this: function appendAllQna(qnaList, num){ for (var i in qnaList){ var qnaCom = ""; qnaCom += "<div class='scomment scommentLine'>"; if(qnaList[i].sellerYn == "Y"){ ...

HTML - header banner with missing links

Currently in the process of learning web development and constructing a practice website, I have encountered some challenges. Specifically, I am attempting to add a background/banner behind the section containing links to other websites. I believe that I h ...

Generating symbols that combine both images and text seamlessly

I am working with a circle image that I need to resize based on its placement. This image is intended to be a background for a character or two of text. Specifically, whenever the number 1 or 2 appears in a certain element, I want the circle to appear beh ...

Internet Explorer 9 users experience a sudden blank page display

Are there any effective methods for diagnosing why a page suddenly becomes blank in Internet Explorer? I am aware that switching to Compatibility Mode 7 is an option, however dealing with the quirks of IE7 can be even more challenging. ...

Getting the ID name from a select tag with JavaScript - A quick guide!

Can you help me retrieve the id name using JavaScript when a selection is made in a select tag? I have tried running this code, but it only alerts undefined. For instance, if I select bbb in the select tag, I should be alerted with 2 Any suggestions on ...