How can I get my text to hug around the top of my image?

Josh Powell

I have been working around with the new adobe CSS Shapes and to no avail, sadly.

Since my browser only supports 20%(should still support what I'm using) I figured I would start to work around this and try something new.

I am trying to have the image in the center of the text and have the text hug the image from the top. If you add a margin-top to the #circle-left/#cirlce-right you will see just blank space above the image, here is a JSFIDDLE.

If you want to try out CSS Shapes then click this link and follow the steps to enable them on your browser.

This section is not normative.

Shapes define arbitrary geometries that can be used as CSS values. This specification defines properties to control the geometry of an element’s float area. The shape-outside property uses shape values to define the float area for a float.

Note: Future levels of CSS Shapes will allow use of shapes on elements other than floats. Other CSS modules can make use of shapes as well, such as CSS Masking [CSS-MASKING] and CSS Exclusions [CSS3-EXCLUSIONS].

Note: If a user agent implements both CSS Shapes and CSS Exclusions, the shape-outside property defines the exclusion area for an exclusion.

Note: A future level of CSS Shapes will define a shape-inside property, which will define a shape to wrap content within the element.

I have achieved my desired effect in every way except I am unable to get my text to wrap above the image/container. I have used margin, padding, top, and positioned it relative.

Here is my CSS, (JSFIDDLE)

html, body {
    margin: 0;
    padding: 0;
}

* {
    box-sizing: border-box;
    -webkit-box-sizing: border-box;
    -moz-box-sizing: border-box;
    -o-box-sizing: border-box;
}

#circle-left {
    shape-outside: circle(50% 50% 50%); /* CSS Shapes, my browser is not supporting this sadly */
    float: right;
    width: 200px;
    height: 200px;
    border: 1px solid brown;
    border-radius: 50%;
    display: block;
    margin-right: -100px;
}

#circle-right {
    shape-outside: circle(50% 50% 50%);
    float: left;
    width: 200px;
    height: 200px;
    border: 1px solid brown;
    border-radius: 50%;
    display: block;
    margin-left: -100px;
}

.left {
    float: left;
    width: 50%;
    overflow: hidden;
}

.fox {
    position: absolute;
    top: 16px;
    left: 50%;
    margin-left: -100px;
    width: 200px;
    height: 200px;
    border-radius: 50%;
    overflow: hidden;
    border: 1px solid brown;
}

Is there anyone out there that knows about CSS Shapes or how I could go about this? I would like to keep it only to css but if javascript is needed I'll give it a try.

I am not trying to support all browser or anything of that nature, just trying to learn the new tools adobe is working on.

Resources

Michael

Took me a long time, but yes. It's effectively the same idea as yours but uses zero width containers to push down the shapes.

.pusher {
    display: block;
    width: 0px;
    height: 100px;  /* top pos of img */
}
#left .pusher  { float: right; }
#right .pusher { float: left;  }

* {
    box-sizing: border-box;
    -webkit-box-sizing: border-box;
    -moz-box-sizing: border-box;
    -o-box-sizing: border-box;
    
    margin: 0;
    padding: 0;
}

.circle {
    display: block;
    width: 100px; /* half width of img */
    height: 200px; /* height of img */
}
#left .circle {
    float: right;
    clear: right;
    
    -webkit-shape-outside: rectangle(
        0px,
        0,
        200px, /* width of img */
        200px, /* height of img */
        50%,
        50%
    );
}
#right .circle {
    float: left;
    clear: left;
    
    -webkit-shape-outside: rectangle(
        -100px, /* 0 - width of img */
        0,
        200px, /* width of img */
        200px, /* height of img */
        50%,
        50%
    );
}

p {
    float: left;
    width: 50%;
    overflow: hidden;
    
    text-align: center;
}

img {
    position: absolute;
    top: 100px;
    left: 50%;
    margin-left: -100px;
    width: 200px;
    height: 200px;
    border-radius: 50%;
    overflow: hidden;
}
<img src="https://placehold.it/200x200" />
<p id="left">
    <span class="pusher"></span>
    <span class="circle"></span>
    Lorem ipsum is a pseudo-Latin text used in web design, typography, layout, and printing in place of English to emphasise design elements over content. It's also called placeholder (or filler) text. It's a convenient tool for mock-ups. It helps to outline the visual elements of a document or presentation, eg typography, font, or layout. Lorem ipsum is mostly a part of a Latin text by the classical author and philospher Cicero. It's words and letters have been changed by addition or removal, so to deliberately render its content nonsensical; it's not genuine, correct, or comprehensible Latin anymore. While lorem ipsum's still resembles classical Lorem ipsum is a pseudo-Latin text used in web design, typography, layout, and printing in place of English to emphasise design elements over content. It's also called placeholder
</p>
<p id="right">
    <span class="pusher"></span>
    <span class="circle"></span>
    Lorem ipsum is a pseudo-Latin text used in web design, typography, layout, and printing in place of English to emphasise design elements over content. It's also called placeholder (or filler) text. It's a convenient tool for mock-ups. It helps to outline the visual elements of a document or presentation, eg typography, font, or layout. Lorem ipsum is mostly a part of a Latin text by the classical author and philospher Cicero. It's words and letters have been changed by addition or removal, so to deliberately render its content nonsensical; it's not genuine, correct, or comprehensible Latin anymore. While lorem ipsum's still resembles classical Latin. Lorem ipsum is a pseudo-Latin text used in web design, typography, layout, and printing in place of English to emphasise design elements over content. It's also called placeholder
</p>

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How can I get my text to position at the top of my divs?

From Dev

How can I get my text to position at the top of my divs?

From Dev

How can i move my popup around?

From Dev

I can't seem to get my image to be absolute to the top of my page and cover the whole page

From Dev

How can I bring my text to the front and leave the image on the background?

From Dev

How to reorder my elements and/or float text around the image?

From Dev

How can I get the URL of my image in Picasso

From Dev

How can i get my location google image?

From Dev

How can I get the text in the bottom left of my buttons?

From Dev

How can I get my appended link text on click?

From Dev

How can I get raw text output of a manual in my terminal

From Dev

How can I get my text to be two lines with padding and ellipsis?

From Dev

How do I get my components on top of my painted JFrame?

From Dev

How can I set my image's hover when hovering my text?

From Dev

How can I make text in my td wrap when it reaches the width of the image in my td?

From Dev

How can I set my image's hover when hovering my text?

From Dev

How can I add a cover image that sits on top of my bootstrap carousel?

From Dev

How can I move sprites around with my finger?

From Dev

How do I get this HTML canvas animation to appear on top of my image?

From Dev

How do I get rid of the white outline around my button?

From Dev

I want to put some text beside my asp image, but I can't seem to get it right

From Dev

My image upload option is not working in my codeigniter application.How can i get solve this?

From Dev

How can I wrap text around image using Bootstrap?

From Dev

How can I wrap text around image using Bootstrap?

From Dev

How do I align my text div next to my image?

From Dev

Only partial image showing as my background image. How can I use CSS to get the full image as my background?

From Dev

Only partial image showing as my background image. How can I use CSS to get the full image as my background?

From Dev

How can I insert an image into my database?

From Dev

How do I get an image in my listview?

Related Related

  1. 1

    How can I get my text to position at the top of my divs?

  2. 2

    How can I get my text to position at the top of my divs?

  3. 3

    How can i move my popup around?

  4. 4

    I can't seem to get my image to be absolute to the top of my page and cover the whole page

  5. 5

    How can I bring my text to the front and leave the image on the background?

  6. 6

    How to reorder my elements and/or float text around the image?

  7. 7

    How can I get the URL of my image in Picasso

  8. 8

    How can i get my location google image?

  9. 9

    How can I get the text in the bottom left of my buttons?

  10. 10

    How can I get my appended link text on click?

  11. 11

    How can I get raw text output of a manual in my terminal

  12. 12

    How can I get my text to be two lines with padding and ellipsis?

  13. 13

    How do I get my components on top of my painted JFrame?

  14. 14

    How can I set my image's hover when hovering my text?

  15. 15

    How can I make text in my td wrap when it reaches the width of the image in my td?

  16. 16

    How can I set my image's hover when hovering my text?

  17. 17

    How can I add a cover image that sits on top of my bootstrap carousel?

  18. 18

    How can I move sprites around with my finger?

  19. 19

    How do I get this HTML canvas animation to appear on top of my image?

  20. 20

    How do I get rid of the white outline around my button?

  21. 21

    I want to put some text beside my asp image, but I can't seem to get it right

  22. 22

    My image upload option is not working in my codeigniter application.How can i get solve this?

  23. 23

    How can I wrap text around image using Bootstrap?

  24. 24

    How can I wrap text around image using Bootstrap?

  25. 25

    How do I align my text div next to my image?

  26. 26

    Only partial image showing as my background image. How can I use CSS to get the full image as my background?

  27. 27

    Only partial image showing as my background image. How can I use CSS to get the full image as my background?

  28. 28

    How can I insert an image into my database?

  29. 29

    How do I get an image in my listview?

HotTag

Archive