Give permission to a SPAN element to exceed the boundaries of its enclosing DIV element

I am attempting to add a watermark sample over an image (and rotate it) using the code below. However, I am encountering issues when the text size is too large or lengthy, causing the words to wrap and create two lines. If I disable wrapping with white-space: nowrap, the text will rotate around a different point if the span becomes too big.

<div class="customize-preview">
    <img src="{{ sample_image }}" id="sample-image" class="customize-image" />
    <div class="customize-overlay">
        <div style="display: table;" class="customize-overlay">
            <div style="display: table-row;">
                <div style="display: table-cell;" class="customize-watermark" id="watermark">
                    <span>Sample Watermark</span>
                </div>
            </div>
        </div>
    </div>
</div>

Here is the CSS used:

.customize-overlay {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
overflow: hidden;
}

.customize-watermark {
    vertical-align: middle;
    text-align: center;
    background-color:transparent;
}

Users have the ability to customize the Sample Watermark text, but if it becomes lengthy, the words may wrap. If a single long word is input, it can expand the containing divs, causing the pivot point during rotation to be incorrect. Ideally, I would like overflowing text to hide so such issues do not occur.

A demo showcasing the problem can be found here: http://jsfiddle.net/yu9Mu/

In the example, you can observe that the text wraps to two lines, whereas I aim for it to remain on one line and overflow. When applying white-space: nowrap, the words do not wrap, however, the span expands infinitely. Moreover, employing -webkit-transform: rotate(90deg) causes the text to rotate around a different point.

Thank you in advance for your assistance!

Answer №1

It seems like all you need to do is adjust the white-space setting in your CSS code.

.customize-watermark {
    vertical-align: middle;
    text-align: center;
    background-color:transparent;
    white-space: nowrap;
}

Check out this fiddle for a live example

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

Adjusting the size of a textarea using jQuery

Below is my modified autogrow code for standard textarea, adjusted to bind on input propertychange in order to capture pastes. (function($) { $.fn.autogrow = function(options) { return this.filter('textarea').each(function() ...

What is the best way to rate a particular image?

while ($row = mysqli_fetch_array($result)) { echo ""; echo "<div id='img_div'>"; echo "<i class='fas fa-times'></i>"; echo "<img class='photoDeGallery' s ...

Storing the result of an Angular $http.get request in a variable

As a newcomer to Angular, I am exploring how to retrieve a JSON object containing a list of individuals from CouchDB using a $http.get call. The JSON structure includes an id, names, and quotes for each person: { "total_rows": 2, "offset": 0, ...

Pricing determined by location on a website created with HTML

We are looking to customize our HTML5/CSS3 website by displaying different pricing tables based on the location of each visitor. Our goal is to have a fixed price for users from Singapore while showing a different price for visitors from other parts of th ...

Restoring list item to standard CSS styling

I am having trouble with the alignment of my links. They are currently displayed in a horizontal manner instead of vertically like this: First link Second link Third link The current layout shows the links next to each other as follows: Firs ...

My website always fits on smaller resolution screens, but annoyingly, a horizontal scroll bar still appears

My website seems to have a horizontal scroll bar on smaller resolution screens, even though it fits. Any suggestions on making it fit better? If you're using a laptop, you'll notice that the scroll bar moves too far right to just show blank grey ...

Retrieving XML data using jQuery and Ajax

Hey there! I am looking to extract information from an XML file. Below is the HTML code snippet: <!DOCTYPE html> <html> <head> <script type="text/javascript"> var xml; $(document).ready(function(){ ...

Mastering the art of iterating through a JSON response

Looking to populate a combobox with data from the database. Upon accessing mystream.php?theLocation=NewYork, I receive the following JSON response: RESULT {"result": [{"theID":"36"},{"theStream":"0817-05131"},{"theLabel":"hgjbn"},{"theLocation":"NewYork ...

Press a button to toggle the selection of all checkboxes on a webpage using jQuery

Apologies if this is a duplicate post. I'm using the code below to achieve the desired outcome: jQuery(document).ready(function () { $('#uncheckAll').click(function () { $(':checkbox').prop('checked', f ...

Angular 12 experiencing CSS alignment issues

In my Angular component, I have the following CSS: .folders { border-left: 5px solid #b8744f; -moz-border-radius: 5px; -webkit-border-radius: 5px; -moz-box-shadow: inset 0 0 1px #fff; -webkit-box-shadow: inset 0 0 1px #fff; /*CORRECTION NEEDED ...

accessing a member of a PHP class from within a jQuery function

I am relatively new to using jQuery, so I may have overlooked something basic. However, despite my efforts, I can't seem to find a solution to my issue. I have a PHP class where one of its attributes (retrieved from the database) is the font color for ...

Display full desktop version on mobile devices with minimized view and no need for horizontal scrolling

While it may seem unusual, my client has requested temporarily removing responsiveness from the site to view the desktop version on mobile. I initially tried removing the responsive meta tag, but encountered horizontal scrolls on the page. My goal is to di ...

Tips on creating a css selector that targets an element depending on its content

Here is some example HTML code: <tbody> <tr class="cart-item"> <td class="image"> <a href="listing_page/PR1"></a> </td> <th scope="row" class="info"> ... </th> <td class="price"> ...

What is the process for setting the input text direction to right-to-left in jQuery mobile?

When using jQuery mobile, I included an input text field: <input type="text" data-clear-btn="true" id="txt_name_contractor"> In my CSS file, I specified the following properties: direction: rtl; text-align: right; However, when typing in this inp ...

Endless Background Image HTML/CSS

I'm currently working on a website where I'd like to have a background image that is black with some characters. The height of the page can vary, being either 'M' pixels or 'N' pixels tall. My goal is to show only one instanc ...

What would be the best way to create a JavaScript function that emulates the functionality of an Upgrade Button?

I am currently working on developing a clicker game and have reached the point where I need to implement a function for the 'upgrade click' button. This function should deduct a certain amount of money when clicked, while also increasing the amou ...

Can someone please provide me with a Javascript code snippet that accomplishes the same function

<script> document.addEventListener('DOMContentLoaded', function () { const menuItems = document.querySelectorAll('.headmenu li'); menuItems.forEach(function (menuItem) { menuItem.addEventL ...

Exploring the contents of a JSON object

Just getting started with jquery and I'm attempting to parse a JSON object. This is my Jquery ajax call $(document).ready(function () { var resource = "v1/projects"; var url = '@Url.Action("Proxy")?resource=' + resource; ...

Bridging the space between two divs with Bootstrap 4

<div class="row"> <div class="input-group col-md-6"> <div class="form-group "> <asp:Label runat="server" ID="Label1" ClientIDMode="Static" Style="margin-left:15px" Text="GL Code" Font-Size="20px" Class="text-bold lblcaption ...

Unable to retrieve multiple data submissions using AJAX in PHP

My form has 2 submit buttons. <form name="posting" id="posting" method="post" action="posting_bk.php" role="form"> <input type="text" name="title" id="title" class="form-control" required="required"> ....additional form fields... <input ...