Image, wrapping text around it and auto hight on div..

NorseMan

Member
For this, I've tried most things, but never quite got it to work the way I want it to. Hope you can tell me about the solution for this. Actually, there are two questions here.

1 - I have a div with another div inside. This is the main div which should contain text and the second div which should contain an article image. Which side, i.e. the right or left side, is controlled by float left or right (CSS). The article images have a fixed size of 350X233(230). The article text must follow the picture's height from top to bottom (height 350px), and if the text is longer than that, it must wrap around under the picture. How to do this?

2 - The same div, i.e. the one that will contain the text has, like the images, a fixed height of 350px, as explained. If this text exceeds the height of 350px in height, the div must also be expanded with the required height. I have tried this with both % and lots of other things. Seems like an impossible task to me.

Do you have the solution to this and how to wrap text around the image? CSS and HTML below.

HTML:
Code:
<div class="content1_background"><div class="oval1"></div><div class="content1_image"></div></div>
<div class="content2_background"><div class="oval2"></div><div class="content2_image"></div></div>
<div class="content3_background"><div class="oval3"></div><div class="content3_image"></div></div>
<div class="content4_background"><div class="oval4"></div><div class="content4_image"></div></div>
<div class="content5_background"><div class="oval5"></div><div class="content5_image"></div></div>
<div class="content6_background"><div class="oval6"></div><div class="content6_image"></div></div>
</div>

CSS:
Code:
div.content1_image {
	background-image: url("../images/content1_image.png");
	margin-top: 25px;
	margin-right: 200px;
	width: 350px;
	height: 233px;
	position: initial;
	image-border: medium;
	border-color: black;
	border-radius: 10px;
	display: inline-block;
  	margin: auto;
  	background-color: #eeeeff;
	/*box-shadow: rgba(51, 51, 51, 0.2) 0px 1px 8px 0px;'/''/*/
  	color: #111;
	/*border-radius: 50%;*/
  	text-align: center;
  	font-size: 90px;
  	float: right;
  	shape-outside: square();
  	padding: 0px;
  	background-clip: content-box;
}
div.content1_background {
	/*text-align: center;*/
	font-family: "Consolas", "Lucida Grande", "Lucida Sans Unicode", "Lucida Sans", "DejaVu Sans", Verdana, "sans-serif";
	font-weight: bold;
	font-size: 14px;	
	color: #ff6633;
	margin: auto;
	margin-top: 25px;
	position: initial;
	background-color: #eeeeee;
	width: 100%;
	height: 250px;
	border: 10px;
	border-color: black;
	/*box-shadow: rgba(51, 51, 51, 0.2) 0px 1px 8px 0px;*/
}
div.content2_image {
	background-image: url("../images/content2_image.png");
	margin-top: 25px;
	margin-left: 50px;
	width: 350px;
	height: 230px;
	position: initial;
	image-border: medium;
	border-color: black;
	border-radius: 10px;
	display: inline-block;
  	margin: auto;
  	background-color: #eeeeff;
	/*box-shadow: rgba(51, 51, 51, 0.2) 0px 1px 8px 0px;'/''/*/
  	color: #111;
  	text-align: center;
  	font-size: 90px;
  	float: right;
  	shape-outside: square();
  	padding: 0px;
  	background-clip: content-box;
}
div.content2_background {
	/*text-align: center;*/
	font-family: "Consolas", "Lucida Grande", "Lucida Sans Unicode", "Lucida Sans", "DejaVu Sans", Verdana, "sans-serif";
	font-weight: bold;
	font-size: 14px;	
	color: #ff6633;
	margin: auto;
	margin-top: 25px;
	position: initial;
	background-color: #eeeeee;
	width: 100%;
	height: 250px;
	border: 10px;
	border-color: black;
	/*box-shadow: rgba(51, 51, 51, 0.2) 0px 1px 8px 0px;*/
}
 
Actuly not Michalio, but nice if your answer could include it as an option for later use in other projects. Like commented out/done passive.
 
I have come a little further in trying. I've been trying this for three days now. I am attaching the CSS and HTML that are relevant. However, I will explain what is happening. I get the text to wrap around the image. What I can't manage to do is create the space I want the text to have for the image. That is, the text that is placed on the underside and the text that is on the right side of the image. If I get the distance to the image on the right of the image, the wrapping function disappears and the text does not fit under the image as it did before when necessary (when the text is so long/too long). This is hopeless!

Can someone please look through what I have done and tell me what is wrong/what I am doing wrong, and please also come up with the solution to the problem so that I can fill in the correct one that is the solution to the problem?

CSS:
Code:
div.content1_image {
	background-image: url("../images/content1_image.png");
	width: 275px;
	height: 181px;
	position: initial;
	float: left;
	margin: auto;
	margin-top: 25;
	margin-left: 25px;
	/*image-border: medium;*/
	/*border-color: black;*/
	border-radius: 10px;
	display: inline-block;
  	background-color: #eeeeff;
	/*box-shadow: rgba(0, 0, 0, 0.65) 0px 0px 0px 3px;*/
  	color: #111;
  	text-align: left;
  	font-size: 90px;
  	shape-outside: square();
  	padding: 0px;
  	background-clip: content-box;
}
div.content1_background {
	/*text-align: center;*/
	font-family: "Consolas", "Lucida Grande", "Lucida Sans Unicode", "Lucida Sans", "DejaVu Sans", Verdana, "sans-serif";
	font-weight: bold;
	font-size: 14px;	
	color: #000000;
	margin: auto;
	margin-top: 25px;
	position: initial;
	background-color: #eeeeee;
	width: 97%;
	height: 300px;
	border: 10px;
	border-color: black;
	border-radius: 10px;
	box-shadow: rgba(51, 51, 51, 0.27) 0px 0px 0.2em, rgba(90, 125, 188, 0.05) 0px 0.25em 1em;
}
div.content2_image {
	background-image: url("../images/content2_image.png");
	width: 275px;
	height: 184px;
	position: initial;
	float: left;
	margin: auto;
	margin-top: 25;
	margin-left: 25px;
	/*image-border: medium;*/
	/*border-color: black;*/
	border-radius: 10px;
	display: inline-block;
  	background-color: #eeeeff;
	/*box-shadow: rgba(0, 0, 0, 0.65) 0px 0px 0px 3px;*/
  	color: #111;
  	text-align: left;
  	font-size: 90px;
  	shape-outside: square();
  	padding: 0px;
  	background-clip: content-box;
}
div.content2_background {
	/*text-align: center;*/
	font-family: "Consolas", "Lucida Grande", "Lucida Sans Unicode", "Lucida Sans", "DejaVu Sans", Verdana, "sans-serif";
	font-weight: bold;
	font-size: 14px;	
	color: #000000;
	margin: auto;
	margin-top: 25px;
	position: initial;
	background-color: #eeeeee;
	width: 97%;
	height: 300px;
	border: 10px;
	border-color: black;
	border-radius: 10px;
	box-shadow: rgba(51, 51, 51, 0.27) 0px 0px 0.2em, rgba(90, 125, 188, 0.05) 0px 0.25em 1em;
}

HTML:
Code:
<div class="content1_background"><div class="content1_image"></div>
Lorem ipsum dolor sit amet. Sit dolorum beatae quo assumenda nisi eum fugiat exercitationem aut obcaecati commodi. 33 enim dolor rem accusamus veritatis non sequi facere ut veniam galisum est error illum qui tempore voluptatem. At necessitatibus sunt a fugit repellendus ab assumenda obcaecati et voluptatibus eveniet ex recusandae molestias est temporibus pariatur voluptatem incidunt.
Rem adipisci laboriosam eum asperiores voluptas est accusantium minima et sint veniam. Sed quas recusandae in voluptas aperiam non eius amet et nobis voluptatum qui assumenda quia. Non voluptates eius ut odio nisi est consectetur quasi est asperiores distinctio et dolorem saepe in molestiae corporis.
Ut placeat nisi et quia tempora qui nihil accusantium ab similique quos non delectus neque ducimus culpa qui distinctio minus. In dolore deserunt est voluptatem iusto quo quia aliquid.
Lorem ipsum dolor sit amet. Sit dolorum beatae quo assumenda nisi eum fugiat exercitationem aut obcaecati commodi. 33 enim dolor rem accusamus veritatis non sequi facere ut veniam galisum est error illum qui tempore voluptatem. At necessitatibus sunt a fugit repellendus ab assumenda obcaecati et voluptatibus eveniet ex recusandae molestias est temporibus pariatur voluptatem incidunt.
Rem adipisci laboriosam eum asperiores voluptas est accusantium minima et sint veniam. Sed quas recusandae in voluptas aperiam non eius amet et nobis voluptatum qui assumenda quia. Non voluptates eius ut odio nisi est consectetur quasi est asperiores distinctio et dolorem saepe in molestiae corporis.
Ut placeat nisi et quia tempora qui nihil accusantium ab similique quos non delectus neque ducimus culpa qui distinctio minus. In dolore deserunt est voluptatem iusto quo quia aliquid.
</div>

<div class="content2_background"><div class="content2_image"></div>
Lorem ipsum dolor sit amet. Sit dolorum beatae quo assumenda nisi eum fugiat exercitationem aut obcaecati commodi. 33 enim dolor rem accusamus veritatis non sequi facere ut veniam galisum est error illum qui tempore voluptatem. At necessitatibus sunt a fugit repellendus ab assumenda obcaecati et voluptatibus eveniet ex recusandae molestias est temporibus pariatur voluptatem incidunt.
Rem adipisci laboriosam eum asperiores voluptas est accusantium minima et sint veniam. Sed quas recusandae in voluptas aperiam non eius amet et nobis voluptatum qui assumenda quia. Non voluptates eius ut odio nisi est consectetur quasi est asperiores distinctio et dolorem saepe in molestiae corporis.
Ut placeat nisi et quia tempora qui nihil accusantium ab similique quos non delectus neque ducimus culpa qui distinctio minus. In dolore deserunt est voluptatem iusto quo quia aliquid.
</div>
 
your css duplicate a lot of properties, you should move these to additional class (for example from .content1_background and .content2_background you can create new .content_background and pass two classes to a div)
add a margin on the right (or also at the bottom) to the .content_image, then add overflow: hidden or overflow: auto to the .content_background.
Additionally, for the .content_background you can add overflow: hidden and add .content_background:hover { overflow: auto; }
 
Yes, I know. I have tried so much different so the CSS is a bit messy.
I found out about it after so many days (no harm)😊👍👌
But it's good to have it well explained and formulated by you. So thank you Michalio.
 
Back
Top