Tips for creating a flexible popover widget

I am facing an issue with my project that has a popover (ng-bootstrap) similar to what I need. The problem is that the tooltips and popovers are not flexible when it comes to resizing the page. To address this, I attempted to put a mat-grid (which works perfectly for me) inside the popover, but it does not behave as expected. The mat-grid shrinks when I adjust the browser width, but the rows are not properly separated as they should be. I want the popover to be more flexible in size. How can I achieve this using either mat-grid or another solution?

Below are some examples of mat-grid layouts. When I make the page smaller, the popover appears too large compared to how Google's layout adjusts its size.

Here is a demo on stackblitz: https://stackblitz.com/edit/angular-nsqsbi-8xn4rg?file=app/main/GridList/grid-list-overview-example.html

I used Bootstrap row and column classes inside the popover body, and I had to comment out the mat-grid part on stackblitz because it was not functioning correctly.

<mat-grid-list cols="1" rowHeight="5:1">
  <mat-grid-tile>1</mat-grid-tile>
  <mat-grid-tile>2</mat-grid-tile>
</mat-grid-list>

Answer №1

When it comes to resizing your pop up window, the browser might not automatically adjust its size. To make this happen, you can use media queries in your code.

By implementing media rules and overriding styles for your ngb-popover-window, you can control the resizing behavior. This code should be added to your grid-list-overview-example.css.

:host ::ng-deep .popover
{    
    background: orange;
    border: 10px solid red;
    max-width: 350px;
    max-height: 50px;
}

@media screen and (max-width: 300px) {
  :host ::ng-deep .popover
  {
    background: lightpink;
    border: 5px solid lightgreen;
    max-width: 50px;
    max-height: 50px;
  }
}

@media screen and (max-width: 205px) {
  :host ::ng-deep .popover
  {
    background: lightgrey;
    border: 5px solid red;
    max-width: 50px;
    max-height: 50px;
  }
}

@media screen and (max-width: 100px) {
  :host ::ng-deep .popover
  {
    background: yellow;
    border: 5px solid lightyellow;
    max-width: 50px;
    max-height: 50px;
  }
}

Key points to note:

  • @media helps determine viewport dimensions
  • :host ::ng-deep is used for style overrides in Angular

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 techniques can be used to create logos that adapt and transform seamlessly as the screen size varies?

The way Responsive Logos adjust their image width when you resize the browser is truly impressive. It seems like they are using SVG images, but I'm not entirely sure how they are able to make the image change dynamically. Could it be through the CSS c ...

What is the effect of SEO on the use of image width and height attributes for a responsive website

Is it true that setting inline width and height for all images is beneficial for SEO and can improve site loading speed? Here's an example: <img src="http://www.example.com/images/free-size.jpg" width="200" height="400" alt="random image" /> E ...

Adjusting the image placement within a modal window (using bootstrap 3)

Behold, an example modal: <!-- Large Modal --> <div class="modal fade bs-example-modal-lg" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel"> <div class="modal-dialog modal-lg"> <div class="modal-content"> ...

Logging in with an External Provider using ASP Core, Identity Server 4, and Angular 2

I have successfully configured an ASP Core App with Identity Server 4 to enable token-based authentication for an Angular 2 SPA. In order to enhance the login process, I am looking to integrate External Providers such as Google and Facebook. However, I am ...

What is a more efficient method for generating HTML code using PHP variables?

My online store showcases a variety of products, each housed in a div with the id content block. The link, image, background, description, and price for each product are all retrieved from a mySQL table. Initially, I planned to store the HTML code below as ...

Angular2 routing does not trigger the Component constructor and Router life-cycle hooks when the router.parent.navigate method is called from a child component

I am currently working on an application that includes child routes. The parent component (App component) consists of 2 routes: @RouteConfig([ { path: '/overview', name: 'Overview', component: OverviewComponent, useAsDefault:true }, { ...

What are some ways to determine if the current tab is the sender of a message in the Broadcast Channel API?

In my Angular application, I am looking to utilize the Broadcast Channel API to ensure that the logged-in state is maintained across different tabs. However, the tab where the user logs in requires a slightly different code execution compared to the othe ...

Utilize ngModel in conjunction with the contenteditable attribute

I am trying to bind a model with a tag that has contenteditable=true However, it seems like ngModel only functions with input, textarea or select elements: https://docs.angularjs.org/api/ng/directive/ngModel This is why the following code does not work ...

Can Angular's built-in internationalization features be used to translate bindings?

Challenge The task at hand involves integrating translations into an Angular 6 application to support static text in multiple languages. The objective is to have the ability to choose a language during the build process without requiring dynamic translati ...

Execute HTML and JS files through Eclipse PDT to view in a web browser

Is it possible to open HTML and JS files in a web browser within Eclipse PDT? Right now, only PHP files seem to launch successfully, otherwise an "Unable to Launch" dialog pops up. Any advice is appreciated! ...

Displaying a single row of a PHP array in bold formatting

I have a MySQL query result showing user information and subjects they have chosen. I want to highlight one specific row by making it bold using PHP while keeping the rest as regular text. How can I achieve this? $resultSet = $db->query ("...my q ...

Transforming jQuery Object into a String after making an AJAX request

If I were to submit a form with some text in the value of user_input, let's say "I am free," through AJAX, and it comes back to me as a string. Once it becomes an Object, how could I convert it back into a string format? Thanks, <!DOCTYPE HTML> ...

Solving the issue of IE7 div overflow-y: scroll causing content to be obscured by the scrollbar

I am facing an issue with a table inside a div (#body) that scrolls along the y-axis. Specifically, in Internet Explorer, the scrollbar is hiding part of the last table cell behind it, causing a shift in the layout of the table columns. This problem does n ...

Sending information from JavaScript to Python scripts: best practices

Within this HTML file, I have included a script where an ajax request is being made to pass a specific string to a Python function. var message = "hello there!!!" $.ajax({ url: "../SCRIPTS/cond.py", type: 'POST', ...

Transmit data from the Windows Communication Foundation to JavaScript

Looking to invoke the WCF service through JavaScript, utilizing AJAX? Check out this resource: Calling WCF Services using jQuery Here's my query: Is there a method to retain some JavaScript-related data after making a request, and then transmit inf ...

Change Observable<String[]> into Observable<DataType[]>

I'm currently working with an API that provides me with an Array<string> of IDs when given an original ID (one to many relationship). My goal is to make individual HTTP requests for each of these IDs in order to retrieve the associated data from ...

The dynamic design of the webpage allows for a fluid layout, where the navigation bar smoothly adjusts its position when

I anticipate receiving criticism from certain users for not conducting enough research. However, I have dedicated two days to this issue and the lack of guidance is starting to frustrate me. Therefore, I offer my apologies if this question has already been ...

Snap to the top of the table with merged columns using scroll feature

I am currently attempting to create a table with horizontal scrolling and snapping behavior for the yellow header columns that span multiple columns. These headers should snap to the end of the red column, while always maintaining alignment at the beginnin ...

Tips for displaying user data from a mongodb database on a webpage, making edits to the information, and then saving the updated data

I have a website where users can register, log in, and update their profile information. However, I am facing an issue where only the data of the first user in the database table is being retrieved. How can I get the data of the currently logged-in user? ...

Turning HTML into an image with the power of JavaScript

Utilizing html2canvas to convert a div into an image, everything is functioning properly except for the Google font effect. The image shows how it eliminates the effect from the text. https://i.stack.imgur.com/k0Ln9.png Here is the code that I am using f ...