[英]How to fit innerHtml into a p tag
問題是我的innerHtml標簽包含多個HTML標簽,包括img標簽。 現在我的代碼是
<div class="container-fluid">
<div class="row pt-5">
<div class="col-md-6 bg-light" style="max-height: 600px;">
<form [formGroup]="editorForm" (ngSubmit)="onSubmit()">
<div class="form-group">
<label for="editor">
<h3 class="fancyFont">Editor</h3>
</label>
<quill-editor [styles]="{height: '250px'}" formControlName="editor"></quill-editor>
</div>
<br>
<button mat-raised-button color="primary">Preview</button>
</form>
</div>
<div class="col-md-6 bg-light p-4" style="background:lightgray;">
<h3 class="fancyFont">Preview</h3>
<p [innerHTML]="editorContent"></p>
<button mat-raised-button color="primary">Save</button>
</div>
</div>
</div>
我想將所有innerHtml放入該p標簽中。 即使p標簽的樣式未應用在innerHtml上。 並且它溢出了p標簽。 我想解決這個問題。 附上圖片以供參考。
您應該在CSS中查詢該容器下的img標簽,並將寬度設置為100%
p img
{
max-width:100%;
}
並確保p標簽或父容器具有定義的寬度
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.