0
我想從輸入字段的寬度繼承我的suggestion div
的寬度,同時將它與對象重疊。我下面的CSS重疊,但不會繼承輸入字段的寬度。我試過讓它達到100%,但它變得比輸入字段更長。CSS Width and Overlap
.suggestion {
cursor: pointer;
background: #FFF;
box-shadow: 0 2px 2px 0 rgba(34,36,38,.15);
padding: 5px 20px 5px 20px;
border-radius: .28571429rem;
border: 0px solid rgba(34,36,38,.15);
z-index: 1;
position: absolute;
width: inherit;
}
.search-res{
margin-bottom: 5px;
}
.search-res:hover{
margin-bottom: 5px;
color: #2196f3;
}
.warning {
color: orange
}
<input type="text" formControlName="name" placeholder="Enter Name..." maxlength="32">
<div class="suggestion" *ngIf="suggestions">
<div *ngFor="let suggestion of suggestions" class="search-res" (click)="onSelectSuggestion(suggestion.name)">
{{suggestion.name}}
</div>
</div>
如果我理解正確的這個,你只是想輸入和建議DIV是相同的寬度? – MegaTron
是的,使分區重疊@MegaTron – Char
好酷。最後,只是爲了澄清。你想要div完全重疊? – MegaTron