The paper-shadow component is not sizing down to fit a div that has display: table-cell on it. I am not sure if this is a bug or a problem with my usage. I am posting here before I submit an issue on the github page to see if you guys also think this is an issue and not a usage problem.
<div id="in" class="section-container">
<h4>In:</h4>
<button class="in-button" on-click="{{ clearInRow }}">Clear</button>
<button class="in-button" on-click="{{ removeInRow }}">-</button>
<button class="in-button" on-click="{{ addInRow }}">+</button>
<core-list id="in-inputs" data="{{ data.in }}" height="39"
style="overflow: hidden; min-width: 324px;" on-core-activate="{{ itemSelected }}">
<template>
<div class="{{ {selected: selected} | tokenList }}">
<paper-input-no-error value="{{ in[0] }}"
class="in-paper-input"
on-change="{{ inChanged }}"></paper-input-no-error>
<paper-input-no-error value="{{ in[1] }}"
class="in-paper-input"
placeholder="Value"></paper-input-no-error>
</div>
</template>
</core-list>
<paper-shadow z="1"></paper-shadow>
</div>
.section-container {
border-radius: 2px;
overflow: hidden;
display: table-cell;
vertical-align: top;
padding: 10px;
}
.section-container > h4 {
display: inline;
}
Here is a screenshot of what is happening. https://www.dropbox.com/s/jtmeboxdjwyph38/Screenshot%202014-08-19%2009.44.43.png
The paper-shadow is the line across the middle of the screen.
I should also mention that how I am using the paper-shadow worked perfectly fine before I just recently did a bower update on all the components. That seemed to break how I am using it. I do not know what version I was previously running, however, I am now running 0.3.5.
Turns out you must add a position: relative to the parent div in order for the shadow to show up. This will fix the problem.
Related
I am trying to add a button to a mat-list-item. This is my current HTML template code:
<mat-selection-list
[multiple]="false"
[class.selected]="currentItem"
formControlName="itemListControl"
>
<mat-list-option
*ngFor="let item of items"
[value]="item.id"
>
<div style="display: flex; justify-content: space-between; align-items: center">
<div style="display: flex; align-items: center">
{{ item.name }}
</div>
<button mat-icon-button>
<mat-icon>edit</mat-icon>
</button>
</div>
</mat-list-option>
</mat-selection-list>
When I inspect the site in my browser, I can see that there is a 16px padding which moves the button to the left inside the list item:
I already tried removing it by adding this to my scss file for the component:
.mat-list-item {
padding-right: 0 !important;
}
For some reason, this does not have any effect. It seems like this is not even applied at all to the element. What am I doing wrong and how can I get rid of this padding (without causing any potentially bad side effects)?
Please use like below. It would work.
.mat-list-text {
padding-right: 0 !important;
}
Thanks!
Use the whole selector(instead of just .mat-list-text, copy all the selector part of the css highlighted in the image above) to remove the the padding, angular material is very hard to modify. Dont forget to add the !important aswell. I had to do this previously. I hope it will work for you aswell.
I'm trying to implement a virtual scroll in my image gallery. My problem is that the implementation doesn't work correctly. First, the elements are displayed in vertical position, when in fact they should respect the horizontal breakpoints and only then respect the vertical scroll. Second, with the scroll elements appear with huge spacing.
Does anyone know how I can solve this problem? thanks
DEMO
HTML
<div [ngSwitch]="viewMode" style="height:100%; width:100%">
<div id="tab2" *ngSwitchCase="'tab2'" style="height:100%; width:100%">
<div
style="margin-left: 16px; margin-right: 16px;height:100%; width:100%"
class="first"
>
<ng-container
*ngIf="
arrayDeNomesCategorias.length == 0 ||
arrayDeNomesCategorias == undefined
"
>
<ul
class="mdc-image-list my-image-list"
style="height:100%; width:100%"
>
<cdk-virtual-scroll-viewport
itemSize="50"
style="height:100%; width:100%"
>
<ng-container *cdkVirtualFor="let i of images; let j = index">
<li class="mdc-image-list__item">
<div class="mdc-image-list__image-aspect-container">
<img
src="https://material-components-web.appspot.com/images/photos/3x2/{{
i + 1
}}.jpg"
class="mdc-image-list__image"
/>
</div>
</li>
</ng-container>
</cdk-virtual-scroll-viewport>
</ul>
</ng-container>
</div>
</div>
</div>
Problem
Correct, but without the implemented scroll :(
I updated your example here.
Your problem was mainly css and there seem to have been (at least) 2 problems:
Your are giving .mdc-image-list__item class min-height: 400px and max-height: 400px. That basically means that all your .mdc-image-list__item containers will have 400px height (so height: auto is kind of useless). Removing this will remove the white space between your images.
If you want to have scroll as well as elements on the same page you should use a flex container with flex-wrap: wrap.
In order to do this I used the following snippet (for your case):
:host ::ng-deep .cdk-virtual-scroll-content-wrapper {
display: flex;
flex-wrap: wrap;
}
You can read more about host and ng-deep here. But please be aware that according to this article (and not only) is recommended to avoid using it in recent version of angular. For the sake of simplicity I used it on your example but you might want to avoid it in production.
(extra) : As a small improve I also removed the duplicated margin: 10px; height: auto; max-height: 400px; properties from .mdc-image-list__item media queries (and only leaved the initial one with no media query). It will be applied anyway since there isn't anything to overwrite it and just changing just the with on the media queries should be enough.
Image
Hi,
I hope whoever reads this is in the best of health and spirit. I am facing some difficulties in positioning the divs. I want the suggestion box of highlighted div to be on top of the horizontal scroll.
I am working on React Js. I am adding my code down here. I really appreciate your help. Thanks
<td>
<div
style={{
width: "125px",
marginTop: "0px",
marginLeft: "5px",
marginRight: "5px",
}}
>
<div style={{position:"relative"}}>
<div
id={"myAutocompleteParentDiv" + this.props.id}
style={{
width="100%";
position="relative"
}}
>
<input class="provider-form" autocomplete="off" id="myAutocompleteID" type="text" name="searchValue" placeholder="" value="" style="margin-left: 0px;">
<span style="position: relative; right: 35px; top: 5px;">
<i class="my-autocomplete-search-icon"></i>
</span>
<div id="myAutocomplete-list-cptCode0" class="myAutocomplete-items" style="max-height: 190px; overflow-y: scroll; background-color: white; width: 125px;">
<div title="searchValue" id="undefined">
<strong>822</strong>32<input type="hidden" value="82232">
</div></div>
</div>
</div>
</div>
</td>
You may add z-index property to your element that you want to raise to top. In your screenshot I cannot tell whether it's in a frame or iframe. If it's in a frame, no matter what trick you do on CSS the element will not be rendered outside it's own frame. Another possible problem is that the element is cropped, in which case you may need to set overflow property.
Ref:
https://developer.mozilla.org/en-US/docs/Web/CSS/z-index
https://developer.mozilla.org/en-US/docs/Web/CSS/overflow
Hi all I think this should be a relatively quick question but since I am a beginner to HTML and CSS I can't seem to figure this out.
I have the following CSS code:
<style>
div.specialspecial {
width: 100%;
height: 0;
padding-bottom: 56%;
position: relative;
margin-left: 160px;
}
iframe {
width: 90%;
height: 100%;
position: absolute;
display: block;
}
</style>
And this html code:
<div class="specialspecial">
<iframe src='dirToLocalHTML' id = 'bg'></iframe>
</div>
It seems that the margin-left set in the div class (which I need as I am using a sidebar on this website) makes it so the content inside the iframe is off center (presumably by 160px). Is there a way for me to use CSS to easily fix this? Or will I need to resort to JavaScript to resize the frame? I am comfortable with learning either approach.
Edit:
Apologies for not providing enough information. Hopefully adding this will help:
This is the body of my html:
<body>
<div class="w3-sidebar w3-bar-block w3-light-grey w3-card-2" style="width:160px;">
<button class="w3-button w3-block w3-left-align" onclick="myAccFunc('demoAcc')">
Accordion <i class="fa fa-caret-down"></i>
</button>
<div id="demoAcc" class="w3-hide w3-white w3-card-2">
Link
Link
</div>
</div>
<div class="specialspecial">
<iframe src='dirToLocalHTML' id = 'bg'></iframe>
</div>
</body>
This code is mainly taken from the example of: https://www.w3schools.com/w3css/tryit.asp?filename=tryw3css_sidebar_accordion
As I am trying to get a similar style for my webpage
I think the best fix is to simply create a container for the iframe that isolates it from the element with the large margin:
<div class="specialspecial">
<div class="pageContent">
<iframe src='dirToLocalHTML' id = 'bg'></iframe>
</div>
</div>
Even with no additional CSS, this should restrain the size of the iframe, which will get its size from the element without the large margin.
It's worth noting that layouts like that, which rely on large margins for side content, are somewhat archaic. Each part of the document should be contained in an element that doesn't care what's happening around it.
<style>
.page-container > * {
display: inline-block;
}
.page-sidebar {
width: 160px;
}
<div class="page-container">
<nav class="page-sidebar"></nav>
<main class="page-content"></main>
<div>
See also: http://www.developer.com/lang/understanding-the-proper-way-to-lay-out-a-page-with-html5.html
My goal: to produce a basic image gallery that can be printed to PDF from the browser as a 3col x 4row grid in a 8.5" x 11" portrait layout. The image URL and a short description are fed from a django app, so I'll neither know how many images will be viewed nor the file names for them.
The code that follows is based on http://www.w3schools.com/css/css_inline-block.asp
It produces an image gallery whose result can be seen as a screenshot here:
Image Gallery Screenshot
My question: is there a way to make the boxes stay in a fixed grid? Some of the boxes are being pushed out of place, but I'm not sure why. If there's a better solution, I hope you'll point me to it.
Thanks!
<!DOCTYPE html>
<html>
<head>
<style>
.floating-box {
display: inline-block;
width: 150px;
height: 180px;
margin: 1px;
border: 1px solid #73AD21;
}
.text-box {
font-size: 9px;
border: 1px solid blue;
}
</style>
</head>
<body>
<div>
<h3>Section 14: Attachments</h3>
{% for inspectionfeedback in inspection.inspectionfeedback_set.all %}
{% if inspectionfeedback.feedback_image.path == "" %}
{% else %}
<div class="floating-box">
<img src="{{ inspectionfeedback.feedback_image.url }}" style="width:140px;" alt=" " >
<div class="text-box">
{{ inspectionfeedback.feedback_inspection_item }}
</div>
</div>
{% endif %}
{% endfor %}
</div>
</body>
</html>
You are using inline-block, and the text is sometimes 3 lines or 2 or even four lines. The inline-block tries to level the text to "baseline" which in turn messes up your grid.
Possible solutions:
use display: block;, and float: left; etc.
use a table :(
use flex-box (if you are ok with css)