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

Adjust the size of a Highcharts chart before printing

I'm facing an issue with a chart that doesn't have a specified height or width. My goal is to print the graph in a taller and larger size when I click on the print button. I attempted to use setSize() function, but since there are no original di ...

Creating a form that can identify both letters and numbers using JavaScript

Is it possible to create an <input> field that can recognize both letters and numbers while disregarding spaces and capitalization? Here is my current progress, aiming for the feedback to display as "right" when 9 H 6 U 8 f is entered in the field, ...

Clicking twice in a row on a map

I am encountering an issue while collecting user input from an infowindow. When I click the 'Save' button in the infowindow to save the input, it inadvertently results in moving my marker on the map by clicking somewhere else. All I really want t ...

Retrieve the identifier of the higher-order block when it is clicked

When I have a parent block with a nested child block inside of it, I expect to retrieve the id of the parent when clicked. However, the event target seems to be the child element instead. Is there a way for JavaScript to recognize the parent as the event ...

Solving the Cross-Origin Resource Sharing problem in AngularJS

While using the http dependency in AngularJS and setting headers for CORS, I am encountering an error. Please check the console.log for more information on the error. The error message reads: "XMLHttpRequest cannot load . Response to preflight request doe ...

Storing the CSS styling for a unique directive in its own dedicated file

Currently exploring Angular and seeking guidance on the most effective methods, as well as a general roadmap for delving deeper into the topic: In my efforts to develop a web application with Angular consisting of various independent widgets, I have opted ...

Generate a loop specifically designed to execute the code following the menu in the script

My website has the code snippet below: let txt_com = document.querySelector(".text_user"); let num_com_user = document.querySelector(".massage_for_user"); txt_com.addEventListener("click", function() { if (this.classList.contains("num_com_user")) { ...

Is it possible to maintain the maximum height and width of a div across all levels of zoom?

In the process of developing a web application, I encountered an issue regarding setting the width and height of a div to a fixed number, regardless of the zoom level. While I was successful in changing the background color of the div across all zoom level ...

Distinguishing Font Sizes in Safari Compared to UIWebView

When the page is loaded in Safari, everything looks perfect. However, when viewed in a UIWebView, all the fonts appear enlarged. I've done my research and tried various solutions like: - Setting WebView.scalesPageToFit = true - Applying default con ...

tips for adding text to an input field after it has been submitted

Is there a way to automatically add text to an input field after the user has entered their information? For example, if a user types "youtube.com" into a search bar, could the input then apply ""? ...

Showing hidden errors in specific browsers via JavaScript

I was struggling to make the code work on certain browsers. The code you see in the resource URL below has been a collection of work-around codes to get it functioning, especially for Android browsers and Windows 8. It might be a bit sketchy as a result. ...

Exploring numerous choices within a multi-select "category" search bar (web scraping)

Looking to scrape data from this French website using Python and the bs4 library: the content is in french :) . Specifically interested in extracting all possible values of a multi-select search bar named 'TYPE DE BIENS'. This type of search bar ...

How can I align multiple lines of text vertically?

Currently employing: #leftfoot {padding-left: 20px; vertical-align: middle;} Unfortunately, this code is not yielding the desired results. Despite searching through numerous explanations, I haven't been able to find a solution that works for me. Can ...

Setting breakpoints on rows in Bootstrap 5: A guide

Looking for ways to modify the diagram in the image using Bootstrap 5 specifically for mobile devices ...

I am encountering issues with an HTML table that is in need of fixing, and I must find a solution without relying on

Can someone help me troubleshoot the structure of this table in the given image? It seems like my rowspan and colspan attributes are not working as expected. I've only used CSS to specify the width and height of the cells. td { width: 60px; ...

What is the method to modify a section of a URL based on form input?

I am currently developing a website that allows users to interact with product images by clicking buttons, entering text into forms, and using a slider to view different angles of the product. My main goal is to extract user input from form fields and dyn ...

What is causing iframes to fail on some websites?

Recently, while I was experimenting with a jQuery tutorial, I encountered an issue where iframes were not working as expected. Surprisingly, only the iframes from w3schools seemed to work fine, leaving me confused about what could be causing the problem. & ...

Preventing scrolling on a YouTube video embed

I have been working hard on developing my personal website. One issue I encountered is that when there is a YouTube video embedded in the site, it stops scrolling when I hover over it. I would like the main document to continue scrolling even if the mouse ...

Building a custom dialog box using Angular Material with HTML and CSS

I've been exploring different approaches to create a customized angular material dialog with a unique header using CSS/SCSS and the TailwindCSS framework. I am aiming for a specific visual effect, similar to what is shown in the figure below. desired ...

Alignment issues with the layout

I am facing an issue with two containers stacked on top of each other. The bottom container is wider than the top one, and both have auto margins set for the left and right sides. I want the top container to be aligned evenly on top of the bottom one. I c ...