Make sure to always keep all stars contained within a div element

How can I keep five stars inside a div even when the screen size is small?

I have created a div with an image and I want to place five stars within that div. However, as I reduce the size of the screen, the stars come out of the box.

Is there a way to ensure that the stars always stay within the box regardless of the screen size?

html

<div class="abc">
    <div class="def">
        <img class="img-fluid Images" src="https://i.ibb.co/3p3D4h6/dmitry-bayer-276d-F1-RG67-Q-unsplash.jpg">
        <div class="row boxImage">
            <star-rating value="4" totalstars="5"
                 (rate)="Rate($event)"></star-rating>
        </div>
    </div>
</div>

Answer №1

Inside the CSS for the boxImage class, the width is currently set to 40%. To learn more about the CSS width property, you can visit this link: https://example.com/css-width-property

It's important to note that according to the documentation:

<\percentage> Sets the width as a percentage of the containing block's width.

This means that your star rating component will always be constrained by 40% of the resized image's width, resulting in limited space for the 5-star display. To address this issue, consider using the value: max-content. You can find more information on this here: https://example.com/max-content-css

.boxImage {
    background-color: white;
    background-repeat: no-repeat;
    height: 50px;
    width: max-content;
    border-radius: 8px;
    opacity: 1;
    max-width: 360px;     
    position: absolute;
    bottom: 8px;
    right: 16px;
    font-size: 18px;}

Make sure to consider browser compatibility when implementing these changes (refer to the provided link).

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

What is the process for obtaining the resolved route data value?

Within my route configuration, I have a resolve that retrieves user JSON data. const routes: Routes = [ { path: 'profile/:id', component: ProfileEditComponent, pathMatch: 'full', canActivate: [AuthGuard], resolve: { use ...

What steps should I take to successfully launch an ASP.NET Core Angular Template without encountering any errors?

While working on a new ASP.NET Core 3.1 Angular Project using Visual Studio for Mac (v8.4.8) and running it in debug mode, I encountered an issue resulting in the following exception: "An unhandled exception occurred while processing the request Aggregat ...

Is there a way for me to retrieve the header values of a table when I click on a cell?

I have a project where I am developing an application for booking rooms using Angular 2. One of the requirements is to be able to select a cell in a table and retrieve the values of the vertical and horizontal headers, such as "Room 1" and "9:00". The data ...

The DHTMLX Gantt tool is throwing an error message saying "TS6137: Type declaration files cannot be

Lately, I've noticed some issues with my code that were not present before. It seems like something may have changed in either typescript or dhtmlxgantt. Whenever I compile the code, I keep running into these errors: Error TS2306: File 'project ...

Creating a specification for a type that lacks a specific concluding character

When utilizing TypeScript, you have the ability to create template literal types such as: type Paragraph = `${string}\n`; const paragraph: Paragraph = 'foo\n'; // valid const word: Paragraph = 'foo'; // invalid But can you d ...

The file path and installed npm package intellisense does not appear in VS Code until I press Ctrl + space for TypeScript

Before pressing ctrl + space, intellisense shows: click here for image description After pressing ctrl + space, intellisense displays: click here for image description Upon updating to vs code version 1.11.0 and opening my project, I encountered an issu ...

How come the variable `T` has been assigned two distinct types?

Consider the following code snippet: function test<T extends unknown[]>(source: [...T], b: T) { return b; } const arg = [1, 'hello', { a: 1 }] const res = test(arg, []) const res1 = test([1, 'hello', { a: 1 }], []) The variabl ...

Querying subdocuments within an array using MongoDB's aggregation framework

Currently, I'm facing a challenge while developing a statistics dashboard for a meditation app. I'm struggling with creating a MongoDB query to fetch the most popular meditations based on user progress. The key collections involved are users and ...

What is the best way to configure Angular viewProviders when using an NgForm in a unit test?

One of the challenges I faced was with an Angular 16 component that required the form it will be placed inside as input. The solution came from using the viewProviders property, which I discovered through a helpful response to a question I had asked previo ...

Issue with Angular2: Modifying onClick property does not cause view to refresh

For my latest project, I am attempting to replicate the functionality of the TodoMvc app using Angular2. One major hurdle I'm currently facing is implementing filtering for the list based on a click event. You can check out my progress on Codesandbox ...

I am encountering difficulties while attempting to import Typescript files. Upon compiling them into Javascript, I am faced with errors in the web browser, specifically the issue of "exports is not defined"

When I run TodoAppUI.js:15, I get an error saying "Uncaught ReferenceError: exports is not defined" In all my classes, I use the export keyword. For example: export class mysclass { public constructor(){} } Even though I have the proper syntax for impo ...

Is there a way for a function to be executed without being detected by surveillance?

Here's the Component I'm working with: @Component({ selector: 'app-signup', templateUrl: './signup.component.html', styleUrls: ['./signup.component.scss'] }) export class SignUpComponent implements OnInit ...

Missing Directory Issue Upon Deploying Node.js App on Google App Engine

I have a Node.js web application built using TypeScript and Koa.js that I am looking to deploy on Google App Engine. The code has already been transpiled into JavaScript and is stored locally in the ./dist/src/ directory. Essentially, I only need to depl ...

Unraveling the mysteries of webpack configuration

import * as webpack from 'webpack'; ... transforms.webpackConfiguration = (config: webpack.Configuration) => { patchWebpackConfig(config, options); While reviewing code within an Angular project, I came across the snippet above. One part ...

Leveraging RXJS Observables and Subjects in combination with Redux is an effective strategy for efficiently managing and processing data

My current project involves utilizing a redux architecture alongside Observables. It has come to my attention that I need to handle data processing after retrieving data from various asynchronous sources. The process is intended to function as follows: ...

What about numerical inputs lacking spinners?

Is there a more efficient way for users to input a decimal number like 64.32, and have it be two-way-bound to a property of type number? I attempted to use <input type="number" [(ngModel)]="size"> However, this displays a spinner which isn't ...

What could be causing the module version discrepancy with the package.json file I created?

Recently, I created a project using create-next-app and decided to downgrade my Next.js version to 12. After that, I proceeded to install some necessary modules using Yarn and specified the versions for TypeScript, React, and others. During this setup, I b ...

Align watermark content to the far left side

Having trouble getting my watermark to align properly on the left side of my website's main content. Here is how it currently looks: The issue arises when I resize the screen or switch to mobile view, as the watermark ends up covering the main conten ...

Struggling to retrieve variable within the .catch function in Ionic 3

I am having trouble accessing the toast variable from the constructor in order to toast errors. It keeps showing as undefined, and I'm not sure why. This issue seems to only occur in this class, which is strange. The error message reads "ERROR TypeErr ...

How can I compel npm to resolve dependencies flatly?

I am working on a project where multiple frontends share a common library. The module dependencies for these projects are managed using npm. In the package.json file of each project, I specify: "dependencies": { "mylib": "file:../<...path...> ...