enclosing the pre tag within a table cell

Despite using the latest Twitter Bootstrap, I am facing some issues with pre tags inside table cells. When a line is too long, it should create a horizontal scroll, but unfortunately, that does not happen.

Check out this example without using the pre tag.

<div class="row">
    <div class="container">
        <div class="col-md-3" style="border: 1px solid red;">
            this is col-md-3? yes :)
            <table class="table">
                <thead>
                    <tr><th>author</th><th>content</th></tr>
                </thead>
                <tbody>
                    <tr><td>somebody</td><td></td></tr>
                </tbody>
            </table>
        </div>
        <div class="col-md-9" style="border: 1px solid black;">test</div>
    </div>
</div>

Here is an example using the pre tag.

<div class="row">
    <div class="container">
        <div class="col-md-3" style="border: 1px solid red;">
            this is col-md-3? no :(
            <table class="table">
                <thead>
                    <tr><th>author</th><th>content</th></tr>
                </thead>
                <tbody>
                    <tr><td>somebody</td><td>why I cannot wrap it?<br/><pre>&lt;?php<br/>class A<br/>{<br/>    function foo()<br/>    {<br/>        if (isset($this)) {<br/>            echo '$this is defined (';<br/>            echo get_class($this);<br/>            echo &quot;)\n&quot;;<br/>        } else {<br/>            echo &quot;\$this is not defined.\n&quot;;<br/>        }<br/>    }<br/>}<br/><br/>class B<br/>{<br/>    function bar()<br/>    {<br/>        // Note: the next line will issue a warning if E_STRICT is enabled.<br/>        A::foo();<br/>    }<br/>}<br/><br/>$a = new A();<br/>$a-&gt;foo();<br/><br/>// Note: the next line will issue a warning if E_STRICT is enabled.<br/>A::foo();<br/>$b = new B();<br/>$b-&gt;bar();<br/><br/>// Note: the next line will issue a warning if E_STRICT is enabled.<br/>B::bar();<br/>?&gt;</pre></td></tr>
                </tbody>
            </table>
        </div>
        <div class="col-md-9" style="border: 1px solid black;">test</div>
    </div>
</div>

After trying many times with various CSS properties, I am still unable to find a solution to this problem.

Answer №1

give this a shot:

<pre><code> input your code example here </code></pre>

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

Is it possible to adjust text wrapping based on the size of the screen?

I am currently facing an issue with my modal form where the text does not wrap properly depending on the size of the modal form. I need help with correcting this using CSS. My current approach involves using angular with new lines and hardcoding line brea ...

Image swaps with timer for button

I am working on a project where I have a page with 5 image buttons arranged horizontally. The objective is to have the images on each button change sequentially every 3 seconds in a continuous loop. Here is my code: $(document).ready(function (){ Beg ...

"Creating dynamic webpage designs with CSS for responsive layouts

Currently, I am in the process of building a website utilizing a CSS fluid layout approach which is rooted in adaptive and responsive web design principles. For this project, I am avoiding using fixed values such as pixels (px) and instead opting for perc ...

Modify CSS class if user is using Internet Explorer version 10 or above

I am attempting to modify the CSS of 2 ASP controls using jQuery specifically for users accessing the site with Internet Explorer 10 or 11. This adjustment is necessary because IE10 onwards, conditional comments are no longer supported. My approach to achi ...

What methods are available to incorporate arithmetic when defining a style attribute?

Is there a way to achieve arithmetic operations in CSS, like calculating margin-left: -60px + 50% of the width of the parent div? I'm eager to find a solution, whether it involves JavaScript or any other method. Any help would be greatly appreciated. ...

How can I use an ajax get request to retrieve a css file from a webpage and then customize the default styles in my program?

Here is my current code snippet: HTML: <h1>Test Message</h1> Default CSS: h1{ font-size: 24px; } Jquery: $(document).ready(function(req, res){ $.ajax({ url:"example.com/test.css", type : "GET", crossDomain ...

Tips for smoothly transitioning from a simple transform to a rotate effect

I need help with an HTML element that needs to rotate when hovered over. Here is the code I have: The issue I'm facing is that I don't want a transition for translateX, only for the rotation. What steps should I take to achieve this? .cog { ...

``Troubleshooting Problem with Tailwind's Flex Box Responsive Grid and Card Elements

Starting point: Preview https://i.sstatic.net/zfzBU.jpg Code : <div class="container my-12 mx-auto"> <div className="flex flex-wrap "> {error ? <p>{error.message}</p> : null} {!isLoading ...

Image staying in place when browser page is resized

Half page browser Full page browser Hello everyone, I could really use some assistance with my program. I'm trying to figure out how to keep my robot in the same position when switching from a half-page browser to a full-screen browser. Currently, w ...

Two liquid level divs within a container with a set height

I hesitated to ask this question at first because it seemed trivial, but after spending over 3 hours searching on stackoverflow and Google, I decided to give it a shot. The issue I'm facing can be found here: http://jsfiddle.net/RVPkm/7/ In the init ...

Triumph Diagrams featuring numerous lines and interactive tooltips

While working on a graph that requires zooming and displaying tooltips for each data point, I encountered an issue with overlapping tooltips when adjusting the data set in Victory's documentation. I came across VictoryPortal as a solution to this prob ...

The ivory pillar on the far right extending over the entire width of the page

Struggling with Bootstrap to create responsive cards, I encountered a white column that's extending off the page and causing an annoying scroll to the right. Can anyone assist me in resolving this issue? If you have any suggestions on how to achieve ...

Combining the Power of Bootstrap with Yii Framework

As a newcomer to the Yii framework, I am looking to incorporate my Bootstrap design into this platform. One issue I have encountered is related to my custom CSS. In Bootstrap, we use navbar-default for styling the navbar. I customized my navbar color by ...

Is there a way to decrease the speed of a text when hovering over it?

Is there a way to create a button that displays text before another text only on hover, with a delay? I've managed to achieve the effect but can't figure out how to slow it down. For example, notice how quickly the word "let's" appears when ...

The height of the href is not displaying correctly when the text-decoration is disabled and it is placed next to

In my design, I have a link positioned next to an image with perfect vertical alignment. Everything looks great when the text has the standard text-decoration, centered vertically and all that. However, as soon as I remove the text-decoration, leaving the ...

Attempting to gather data from an HTML form and perform calculations on it using JavaScript

Looking for help with extracting user input from HTML and performing mathematical operations in JavaScript. Coming from a Python background, the variable system in JavaScript is confusing to me. Can someone provide guidance on how to achieve this? <div ...

Responsive left and right image styling in CSS and HTML

I have designed a landing page with fixed left and right images and content in the middle. It looks fine on desktop view, but on mobile view, the images are overlapping the content. How can I resolve this issue? <div class=" ...

How can I adjust the regular font size within a paragraph or link using bootstrap?

Looking at the fs-* classes can be very helpful, you can find them here: https://i.sstatic.net/l1Y22.png The issue I'm facing is that these classes only work for h1 to h6 headings, and not for smaller text. For example, I am unable to adjust the fo ...

When the enter key is pressed on a child modal dialog, it triggers the enter action on the parent modal dialog in IE11 and

Having two bootstrap modal dialog windows, where one creates the other, is causing a problem. When the enter key is pressed on the child's text input, it triggers an event on the parent as well. If the last focused button on the parent was the one to ...

What is the best way to prevent text-decoration from being applied to icons when utilizing font-awesome inside a hyperlink?

I recently began using FontAwesome and it's been going well. However, I have a question about using it with an anchor tag that has text-decoration:none, and on hover text-decoration:underline. Whenever I hover over the link, the icon also receives the ...