Ensure that both the div element and its contents are restricted to a maximum width of

I'm having trouble arranging the display of information next to a plant image. I want to ensure that the information stays on the right side of the image when the screen reaches a specific minimum width.

The issue arises when the information includes a line longer than the normal width, causing the information div to drop below the image.

Here is an example with acceptable line length (no wrapping): https://jsfiddle.net/o3sjug9q/
And here is an example with excessive line length (resulting in wrapping): https://jsfiddle.net/seL72mt9/

Is there a way to make the details div wrap its text instead of wrapping itself onto the next line?

<div class="outer">
<div class="slidecontainer row" id="biodivslider" data-id="1">
<div class="sliderbtn nowrap" onclick="bwdpic()">&lt;</div>
<div class="wrap">
  <div class="detailimg"><img src="http://www.nachhaltiger-weinbau.net/wp-content/plugins/biodivslider/img/Milchsterne/Dolden-Milchstern_Ornithogalum_umbellatum-Tci_2004.jpg" class="detailimg"></div>
  <div class="details">
    <p><span class="detailslabel">Name:</span><br>Milchsterne</p>
    <p><span class="detailslabel">Latin Name:</span><br>(Ornithogalum spec.), O. umbellatum, O. nutans</p>
    <p><span class="detailslabel">Location:</span><br>moderately dry, sandy, indicator of warmth, moderately nitrogen-rich</p>
  </div>
</div>
<div class="sliderbtn nowrap" onclick="fwdpic()">&gt;</div>
</div>

</div>

CSS:

div.outer {
  width: 833px;
  height: 491px;
  background: lightblue;
}
div.slidecontainer {
  max-height: 300px;
}

div.row {
  display: table;
  width: 100%;
  table-layout: fixed;
  border-spacing: 10px;
  max-height: 300px;
}

div.row > div {
  float: none;
  display: table-cell;
  height: 100%;
  width: 100%;
}

div.row > div.wrap > div {
  float: left;
}
#
div.detailimg {
  height: 300px;
  width: 300px;
}

img.detailimg {
  display: block;
  max-height: 300px;
  max-width: 300px;
}

div.details {
  max-width: 100%;
  vertical-align: middle;
  word-wrap: break-word;
  overflow: visible;
}

span.detailslabel {
  font-size: smaller;
  font-weight: bold;
}

div.details > p {
  line-height: 90%;
  word-wrap: break-word;
  overflow: visible;
}

div.sliderbtn {
  font-size: 50px;
  font-weight: 900;
  min-height: 300px;
  height: 100%;
  width: 60px !important;
  line-height: 300px;
  text-decoration: none;
  vertical-align: middle;
  text-align: center;
  cursor: pointer;
}

Answer №1

https://jsfiddle.net/k83uYsJp/

1.) Remove the property overflow: visible; from both div.details and div.details > p

2.) Set the max-width of div.details to be calc(100% - 200px)

Answer №2

modify

div.details {
max-width: 100%;
vertical-align: middle;
word-wrap: break-word;
overflow: visible;
}

to

div.details {
max-width: 50%;
vertical-align: middle;
word-wrap: break-word;
overflow: visible;
}

if you adjust the sizes of your images, update the max-width in the CSS class of your images to 50% as well.

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

Javascript menu toggle malfunctioning with sub-menus

I am in the process of creating a responsive menu for a complex website. The horizontal menu transitions into a vertical layout on smaller screens, with javascript used to toggle the sub-menu items open and closed when clicked. One issue I am facing is wit ...

Is your navigation bar failing to extend to the entire width of the page

Click Here for the Host Folder If you follow the link and then click on "all.html," you will come across a page with an incomplete navbar. The li elements in the list appear to be stacking oddly, causing "Member Resources" and others to show up in a row b ...

Stop angular material css styles from affecting neighboring components

Currently, I have overridden the angular material style in my global SCSS style as follows: .mat-form-field-infix{ padding: 0.5em 0 0.5em 0 !important; } However, I now need to apply a different padding to the same element in my component for addition ...

What steps should I take to ensure that clicking this button triggers the API request and returns the data in JSON format?

I'm attempting to have the button with id 'testp' return an api request in json format, however it seems to not be functioning properly. You can find the HTML code link here: https://github.com/atullu1234/REST-API-Developer-1/blob/main/js-bu ...

Overlapping borders in Bootstrap 4 design

Working on my project with Bootstrap 4 and encountered a coding issue. Here is the code snippet: .form-info-tab { border: 1px solid #ccc; border-collapse: separate; border-spacing: 0px; padding:5px; text-align:center; } <link ...

Prevent Scrolling on Body with W3 CSS

While implementing scroll body lock packages like body-scroll-lock, react-scrolllock, or tua-body-scroll-lock alongside the W3 CSS package, I have encountered an issue where the body remains unlocked even when the designated element is active or open (e. ...

Introducing the new and improved SweetAlert 2.0, the ultimate solution for

I am currently utilizing SweetAlert2.0, known as "This One" <script src="https://unpkg.com/sweetalert/dist/sweetalert.min.js"></script> It is functioning properly; however, I would like to display a table, div, or HTML element within this swe ...

Exploring elements using dynamic xpaths in selenium

When working with Selenium WebDriver, I am facing difficulties selecting the <input class="cs-autocomplete-input" tabindex=""> element due to its fluid ID. This is because there are multiple items with the same class name on the web page, making it c ...

When utilizing the --watch flag, Node-sass will fail to function properly

Encountering an issue with the "--watch" or "-w" flag when running node-sass. After installing node-sass as a devDependency and setting up a script to compile SCSS code, everything runs smoothly without any flags. However, adding the "--watch" flag causes ...

In what ways can the accessibility of a website be impacted by using CSS

After reading numerous articles on Google and Stack Overflow, I have decided to ask my question straightforwardly in the hopes of receiving a clear and direct answer. Adding another layer to the discussion about whether Does opacity:0 have exactly the sam ...

Transformation of visuals with alteration of status

I am attempting to change the image of a door from closed to open when the status changes in my home automation dashboard. I need help with this task. <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&qu ...

Sharing details of html elements using ng-click (AngularJS)

I am currently exploring options to enable users to click on a "open in new tab" link, which would essentially transfer that HTML element into a fresh window for their convenience. I am seeking advice on how to achieve this. At the moment, I am able to la ...

Information from contact forms gets inputted into the URL

Currently, I am in the process of developing a website and implementing a Contact Form that allows customers to email me directly. To test if the mail function is working correctly, I am using a Test Mail Server listening on Port 25 through a WAMP server v ...

Position the middle character within a span that has the identical width and height

My goal is to align characters in the center of a span. CSS span{border-radius:10px; width:20px; height:20px; color:#fff; background:#cc0000; text-align:center; line-height:20px; display:block;} HTML <span>+</span><br> <span>-&l ...

Dynamic collapsible containers

I discovered a useful feature on w3schools for collapsing elements: https://www.w3schools.com/howto/tryit.asp?filename=tryhow_js_collapsible_symbol However, I would like to reverse it so that all elements are initially shown when the page loads, and then ...

Enhancing nouislider jQuery slider with tick marks

I have integrated the noUIslider plugin () into one of my projects. I am seeking guidance on how to display tick marks below each value on the slider. This is the current initialization code for the slider: $slider.noUiSlider({ 'start': sta ...

What's the best way to conceal scrollbars in Nuxt2 whilst preserving one for the description?

The Issue My goal is to remove scrollbars from all pages (which I achieved successfully), but keep one visible for a specific section of description. What I Attempted I tried adding the class .scroller and only displaying it for the <div> containi ...

I'm currently attempting to determine the total cost of a series of operations, however, I am not receiving any results

Here is the code snippet from my HTML file: <tr> <td><input id="z1" type="number" oninput="calculateSubTotal()"> </td> <td>Shirts - WASH - Qty 1 to 4</td> <td>2.50 ea</td> ...

Divide the webpage into four equal sections, each showcasing distinct information sourced from the database

Is there a way to divide my page into 4 sections with data from a database source? Currently, I am displaying the data from the database in a single table, but I would like to split it into four parts, each showing different results from the database. Ad ...

The Date validation script in Javascript is malfunctioning

I encountered an issue where the script I used in my HTML file didn't work as expected. The purpose of this script was to prevent users from submitting a date greater than today's date. Interestingly, when I copied the same script to another HTML ...