Ways to control the maximum distance a CSS marquee can scroll?

I'm having an issue with this marquee scrolling over other elements, and I can't figure out why. I attempted to use max-width to constrain the scrolling text to a specific container (within the red border on top of lorem ipsum), but it's not working as intended. I would appreciate any solutions that utilize CSS marquee, but I'm open to JavaScript solutions as well if they are easier. Thank you!

body {
    background:#222;
}

#sidebar_container {
    background:transparent;
    border:1px solid red;
    width:200px;
    height:auto;
    position:fixed;
    top:100px;
    left:220px;
}

.marquee {
    animation:marquee 5s linear infinite;
}

@keyframes marquee {
    0% {transform: translateX(100%);}
    100% {transform: translateX(-100%);}
}

#sidebar_title {
    font-family:Helvetica;
    font-weight:bold;
    text-transform:uppercase;
    text-align:center;
    color:#fff;
    font-size:20px;
    margin:0 0 10px 0;
}

#sidebar {
    border:1px solid red;
    background:transparent;
    font-family:arial;
    font-size:14px;
    width:200px;
    height:auto;
    text-align:center;

}

.desc_container {
    border:1px solid red;
    color:#fff;
    margin:10px 10px 10px 10px;
}


.desc {
}
<body>

    <div id="sidebar_container">
        <div id="sidebar_title"><div class="marquee">Marquee Text</div></div>
        <div id="sidebar">
            <div class="desc_container">
                <div class="desc">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</div>
            </div> <!-- desc container -->
        </div> <!-- sidebar -->
    </div> <!-- sidebar container -->

</body>

Answer №1

Are you satisfied with the outcome? I have applied the overflow: hidden style to #sidebar_title

body {
    background:#222;
}


#sidebar_container {
    background:transparent;
    border:1px solid red;
    width:200px;
    height:auto;
    position:fixed;
    top:100px;
    left:220px;
}


.marquee {
    animation:marquee 5s linear infinite;
}


@keyframes marquee {
    0% {transform: translateX(100%);}
    100% {transform: translateX(-100%);}
}


#sidebar_title {
    font-family:Helvetica;
    font-weight:bold;
    text-transform:uppercase;
    text-align:center;
    color:#fff;
    font-size:20px;
    margin:0 0 10px 0;
    overflow: hidden;
}


#sidebar {
    border:1px solid red;
    background:transparent;
    font-family:arial;
    font-size:14px;
    width:200px;
    height:auto;
    text-align:center;

}


.desc_container {
    border:1px solid red;
    color:#fff;
    margin:10px 10px 10px 10px;
}


.desc {
}
<body>

    <div id="sidebar_container">
        <div id="sidebar_title"><div class="marquee">Marquee Text</div>&
</div>
<div id="sidebar">
<div class="desc_container">
<div class="desc">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</div>
</div> <!-- desc container -->
</div> <!-- sidebar -->
</div> <!-- sidebar container -->

</body>

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

I'm looking to create a card carousel using HTML and Bootstrap, but for some reason, the cards are not aligning properly and are stacking

I need assistance with creating cards in a loop at runtime. However, the cards are displaying vertically aligned to each other instead of horizontally as intended. I have already tried using col-md-4 but it did not work. enter code here <div class=&q ...

Retrieve isolated scope of directive from transcluded content

I am not certain if it is possible, but I am essentially looking for a reverse version of the '&' isolate scope in AngularJS. You can check out this Plunkr to see an example. In essence, I have created a custom directive that provides some r ...

A variety of personalized Vimeo play buttons

Recently, I stumbled upon a genius solution by Chris Coyier for creating custom Vimeo play buttons. It worked perfectly for my needs, but now I'm facing a challenge - how to make it function with multiple videos on the same page. I tried swapping out ...

Guide to incorporating external CSS and JavaScript into an Angular 2 project with Express.js and Node.js

As a newcomer to Angular2 and NodeJs, I am eager to learn how to integrate external CSS and JS in an Angular2 and Nodejs express app. Specifically, I am looking to integrate a bootstrap admin theme into my Nodejs application. The screenshots below provide ...

I am experiencing an issue where the submenu does not appear when I hover over the elements in the navigation bar

How can I make the submenu appear when hovering over the corresponding navigation element on the navigation bar? Here is how I set the display to none for the second level navigation list: nav ul ul { position:absolute; top: 100%; background-colo ...

Angular components are not inheriting the Bootstrap row class as expected

Within my codebase, there are numerous controls declared in the following manner. <div class="row"> <div class="col-sm-12"> <div>Caption</div> <input type="text" class="form-control"> </div> </div> In ...

Height constraint disregarded by anchor

I am facing an issue with a large textual menu where the active link space is overlapping onto the other menu items. This is causing difficulty in accurately clicking on a link. For reference, you can check out this example: http://jsfiddle.net/dhyz48j3/1 ...

The noclose feature in Twitter Bootstrap is malfunctioning when placed within a div

I have a PHP page named a.php that contains the following code: <ul class="dropdown-menu noclose"> This code functions correctly, preventing the drop-down menu from closing until the user clicks outside the box. However, when I load the entire a.p ...

Why won't my dropdown menu work properly with JavaScript on certain pages?

Being new to javascript, I encountered an issue with a function that I recently modified. When a user selects "Yes" from a dropdown menu, it should generate 3 text boxes within a specific div area. Below is the code for my form dropdown: <select name= ...

Change the P element to a Span element while maintaining the existing content using the replaceWith

I'm having trouble replacing a p tag with a span while keeping the actual content intact. Can anyone assist me with this, please? $('.anim-letters p').replaceWith( "<span class='letters'>" + $('this').text() + "< ...

Utilizing Material-UI CssBaseline with React JS

Looking to enhance the consistency of my new React app with a sleek design using Material-UI. Want it to be easy to maintain, so decided to start with the default theme. Trying out cssBaseline from Material-UI but running into issues. Not very familiar wit ...

Converting canvas illustrations into HTML files

I am in the process of creating a drawing application that will be able to export into HTML/CSS/JavaScript. I plan to use this tutorial as a foundation for the drawing functionality. My goal is to take all the rectangles within the this.shapes = [] array a ...

Display the list of articles in a three-column format

Is there a way to create CSS rules to display articles in three columns, like the example shown in the image below? The preferred HTML markup is: <div>1</div> <div>2</div> <div>3</div> ... <div>6</div> The ...

Obtain the breakpoint value from Bootstrap 5

We have recently updated our project from Bootstrap 4 to Bootstrap 5. I am trying to retrieve the value of a breakpoint in my TypeScript/JavaScript code, which used to work in Bootstrap 4 with: window .getComputedStyle(document.documentElement) .g ...

Is there a way to integrate a Control + F style text search box into a website using an iframe

My website has a lengthy iframe filled with text from another domain that I have no control over. When I need to search for specific text within this iframe, I typically press CTRL+F to locate and highlight the desired text. Previously, using CTRL+F was s ...

What is the best way to place a row with a width of 25% at the conclusion of the row?

I utilized https://i.sstatic.net/aQ6Ew.png by implementing this code. <div class="row mw-md-100 d-flex w-25 justify-content-end mb-2" > <div class="col-md-12"> <nb-select fullWidth class="mw-md-100 ...

Other than the doctype declaration and the opening html tag, what additional markup can reside outside of the head and body elements in an HTML document

When it comes to an HTML document, the majority of content is typically found within the html head and body. However, what other elements can exist outside of these sections? ...

Creating a 3-column div with varying sizes of text in another div at the center position

I am attempting to create a 3-column layout using only DIVs, but I am facing some challenges. If I were to use tables in the traditional HTML 4 way, I could achieve this: <div style="width:100%"> <table width="50%" align="center"> ...

The waveform's bottom appears distorted when using Bootstrap

I'm currently experimenting with creating a header wave in Bootstrap CSS using SVG shape. However, I encountered an issue when implementing bootstrap into the HTML code - my design resembles the second image instead of the desired look of the first on ...

Learn how to create a responsive flickr embedded video with Bootstrap!

I'm struggling to make the embedded video responsive. I attempted the solution mentioned in a Stack Overflow post but it didn't work for me. The video's width remains the same and doesn't scale down properly, appearing out of bounds on ...