Reputation: 79
Please check and run this example.
img {
width: 10px;
}
pre {
overflow: initial;
white-space: pre-wrap;
word-wrap: break-word;
word-break: break-all;
max-width: 300px;
border: 1px solid;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=">
<title></title>
</head>
<body>
<pre>Lorem ipsum, dolor sit amet consectetur ad<img src="https://randomm.cdn.bcebos.com/edit%20(1).svg"></img></pre>
<pre>Lorem ipsum, dolor sit amet consectetu<img src="https://randomm.cdn.bcebos.com/edit%20(1).svg"></img></pre>
<pre>Lorem ipsum dolor sit amet consectetur adipisicing elit. Quod voluptate nesciunt velit? Officiis doloribus fugit et harum nobis assumenda<img src="https://randomm.cdn.bcebos.com/edit%20(1).svg"></img></pre>
</body>
</html>
I need to let the icon follow the text inside the pre
tag, but at some situation the text length will be exact the max-width of the pre
tag, which leads to make the icon present at the next line.This has a very bad user experience. Please tell me how to design this edit-icon. Thank you.
Upvotes: 0
Views: 210
Reputation: 51
You can't do it. It's a staic image.
Solution: You can use Icon from https://fontawesome.com/icons
Steps:
Example:
<i class="fas fa-edit"></i>
Upvotes: 1