Responsive grid with a circular image and cut out div - css

I need some help here.
I am trying to achieve the following layout - a rectangular div containing text on the left and circular image on the right, similar to this (but reverse order). I'm also using Bootstrap for layout.
example
The issue with the solutions proposed on StackOverflow is that they require definining height and width of the circle and I need it to be responsive.
The closest was to use a radial gradient, however the cut out area from the rectangle did not have the same radius as the circle and the gap was too large.
This is what I've got so far:
<div class="cut-out-grid cut-out-grid--alt">
<div class="cut-out-grid__image-section">
<div class="image-rounded">
<div class="image-rounded__wrap">
<img class="image-rounded__image" src="/images/stock/dog.png">
</div>
</div>
</div>
<div class="cut-out-grid__text-section cut-out-grid__text-section--tertiary">
<div class="cut-out-grid__text">
<h3 class="feature-grid__title">lorem ipsum dolor sit amet.</h3>
<p>lorem ipsum dolor sit amet, consectetur adipiscing elit</p>
<span class="button-grid__item">
Lorem ipsum
</span>
</div>
</div>
</div>
</div>
And Sass:
.cut-out-grid {
#extend .row;
#extend .align-items-center;
&__image-section,
&__text-section {
#extend .col-6;
}
}
Any help will be appreciated, thanks! :)

Okay, so I actually ended up finding a solution myself by adding this:
&__image{
border-left: 1.2em #ffcd41 solid;
box-sizing: content-box;
position: absolute;
bottom: -210px;
left: -100px;
}
which seems to have done the trick.
The key was to focus on the image div, not text, as I wanted the cut out shape to be the same radius as the radius of the circle.
This is why previous solutions suggesting radial-gradient on Stack were not applicable in this case.
Box-sizing: content-box; was necessary to ensure the border does not eat into the image.
The border is what creates the cut-out effect. I was experimenting with padding on the image wrap before, but that did not achieve the effect I wanted and made the image smaller despite box-sizing: content-box added. I'm not entirely sure why and need to research this further.
Now I will focus on getting rid of the px values and adding necessary media queries.

Related

CSS for creating a baloon as a hint

I'm tryng to create a baloon as a hint on top of the word in text. The text inside the baloon would have some block layout, so I need to put this layout into a rectangular block and display it relative to the word of interest. I'm trying to define CSS styles for the internals of the baloon, but so far that doesn't work.
Here is an example of the text:
<p>Lorem ipsum dolor sit <span class="needs_hint">amet<span class="baloon">hint</span></span>, consectetur adipiscing elit.</p>
The word "amet" is the one I need the hint for, and I wrap it with an inline span. The staff needed for the hint is extracted into a nested span.
After applying the CSS below I have a hint floating on top of the word "amet", and that is expected and desired:
.needs_hint {
position: relative;
display: inline-block;
}
.baloon {
width: 200px;
position: absolute;
bottom: 125%;
left: -50%;
margin-left: -60px;
border-width: 1px;
border-style: solid;
}
Now I need to add text with more complex layout into the baloon. I'm replacing the word "hint" with a more complex html that contains a <div>:
<p>Lorem ipsum dolor sit <span class="needs_hint">amet<span class="baloon">inline hint<div class="hint">inline-block hint</div></span></span>, consectetur adipiscing elit.</p>
I'm defining the CSS for this <div> line that:
.hint {
position: relative;
display: inline-block;
}
This however extracts the "inline hint" inside the baloon, but leaves the "inline-block hint" part inside the text. What CSS would allow me to display some block html with divs, tables, etc?
I've found an ad hoc solution to my problem here: How to create a pure CSS tooltip with HTML content for inline elements.
The inner <span> has to be replaced with a <button>, as this is the only inline element that allows to contain block elements.
The solution is quite unusual and surprising to me, as <button> has very different semantics, so other solutions are welcome. I would also like to hear the justification for this usage of the button tag.

Responsive Cross Browser and Flexible way of "cross-background" images

Can anyone please point me out, or name some tecnhiques that may exist in order to achieve this effect, on a properly way:
Like this:
and again:
As you may notice, the point is to connect both lines. Some of those lines come from text boxes, that, since we wish to properly use EM unit for font-size, the box around the text, may change.
I have never done this before, I would appreciate any point outs, in order to investigate this "effect" further please.
Thanks in advance.
It doesn't matter if the fonts in the text boxes are in EM. If the font size change, the text boxes size will change, but that it doesn't mean that the space between them also has to change (it could has a fixed height -the background height-).
Here's a really basic example (try changing the body font-size):
<html>
<head>
<style>
body { font-size: 12px;}
.text { border: 1px solid #999; padding: 15px; font-size:1em; }
.line { background: url(http://www.agavegroup.com/images/articles/photoshopCurvedLine/curveFinal.gif) no-repeat center center; height: 50px; }
</style>
</head>
<body>
<div class="text">
Lorem ipsum dolor sit amet, consectetur adipisicing elit.
</div>
<div class="line"></div>
<div class="text">
Eum, quis consequuntur culpa ex eius totam nemo.
</div>
</body>
</html>
If you do want the space between boxes height changing if the font-size change, you should set it height to EM and use a background images that's, lets say, doubled the container original height (so when the height change, more background it's revealed). You can see this changing height: 50px; to height: 7em; on the .line {} rule (the example image I've used it higher than the container).
This a really basic example. The markup depends on the design. If you need something more accurate (like: you need that the line starts and ends in specific spot), you should probably use absolute/relative positions.

Sticky footer in responsive web - overlap content when window resize

I'm making a liquid page, and I have an horizontal menubar (ul) absolute positioned to bottom (sticky footer).
No problem with this stuff, but when I resize the browser, obviously the inner elements in the menu stacked upwards each other, making the menu too high and overlapping the main content.
Is there any way to (any of the following)
make the absolute postioned menu grow "downwards"?
or to setting the edge that aligns to the bottom in a certain high (to make it grow from that point to bottom)?
or give layout to the menu making it to push the above elements (I've tried playing with overflow but doesn't work
for me)?
That's the html:
<div class="container">
<div class="izda">
Foo
</div>
<div class="dcha">
<p>Lorem ipsum dolor</p>
<p>Lorem ipsum dolor</p>
<p>Lorem ipsum dolor</p>
<p>Lorem ipsum dolor LAST</p>
<ul>
<li>Item</li>
<li>Another</li>
<li>More</li>
<li>Item</li>
</ul>
</div>
</div>
And the css:
.container {position:relative}
.izda {background:red;
height:20em;
display:inline-block;
width:20%;
vertical-align:top;
}
.dcha {background:gold;
display:inline-block;
width:78%;
margin-bottom:3em;
}
ul {position:absolute;
bottom:0;
background:pink;
margin:0;
padding:0;
max-width:100%;
}
ul li {float:left;
list-style:none;
border:1px solid black;
margin:0 1em;
padding:1em;
}
A working example here: http://jsfiddle.net/KQhLs/2/
If you write more paragraphs, the menu go down properly thanks to the margin bottom of his father.
But when resizing the frame you can see the overlapping effect.
Thanks in advance. The web are supposed to work only in modern browsers and, if possible, with pure css (no JS).
EDIT: I think the wind is blowing these ways:
How to avoid fixed element from hovering page contents?
To end at this:
Sticky Footer for Responsive Site
But there's no useful answers...
Well, in fact I can prevent this behavior with mediaqueries, that's simple. But I'd like to know if it's there a "one for all" solution.
EDIT2: I have just read A list apart - Exploring footers. Aside JS solutions I tried all, but the problem stills here - if you put floating elements inside the footer, it overlaps the main content.
Also, I have read CSS Sticky Footer and it seems it have same problem.
I can't figure that this is impossible to achieve with pure css... should I give up?
make the absolute postioned menu grow "downwards"?
On your <ul> footer element, replace bottom:0 with top: 83%
Or if you want to control it pixelwise, replace bottom:0 with top: 100%; margin-top: -54px;
make sure your wrapper/container is relative. Underneath it place your footer as relative and add top:100%

CSS: How to make consecutive lines in Paragraph Go over Left Floated Image with height

I have an image that is floated Left Next to the image there is text wrapped around the image.
I want to put the first line of text next to the image and the consecutive lines of text to go over the image. Is that possible?
Check out these images to see what I'm trying to achieve:
The red square is the image.
<img class="someImage" ... />
<span class="someText" ... />
.someImage { float:left; }
.someText { line-height:1.5em; margin-top:10px; padding:0 22px; }
The image has a height. I want to wrap the lines of text (after the first line of the paragraph) on top of the image. I only want the first line to wrap around the image.
You can use a workaround with text-indent and a background image. Demo.
HTML
<div id="text">
Lorem ipsum dolor sit amet...
</div>​
CSS
#text {
background:url(your-image.jpg) top left no-repeat;
text-indent:100px;
padding-left:20px;
}
After looking into it, I think text-indent is exactly what you are looking for.
http://www.w3schools.com/cssref/pr_text_text-indent.asp
if you are using float for positioning, it is difficult to achieve this as float does not break the regular flow of positioning. Use absolute positioning instead and z-index property to overlay. Then indent the first-line with left-margin, or text-indent property.
You can do it more easily if you put the image in background.
You can gain more control of the first line using the ... wait for it ... first-line selector
p:first-line {padding-left:50px;}

CSS - Nested DIV : Clear Sub Styles

I am sure sure if this is even possible due to the nature of CSS and being cascading, but I will try anyway.
I am creating a Terms and Conditions box which will contain some key elements that the user will select. Since the T&C's will have form components (radio buttons, check boxes). I don't really want to go through the trouble of putting it into an IFrame and getting the user input that way.
I figured using a with the overflow: auto property added, I could create an scrolling box with the T&C's and have the user select their options that way.
Well, because the T&C's have some mark up which would be directly affected by the sites css, I need to figure out a way to have this div not use the main CSS of the site.
Here is some sample code which would be similar to the approach I am trying:
<html>
<head>
<style>
div
{
border: solid 1px #000;
}
div small
{
font-size: 17pt;
}
</style>
</head>
<body>
<div style="overflow: auto; width: 500px; height: 300px;">
<small>This is small text</small>
<div>
<small>This is small text</small>
Lorem ipsum dolor sit amet, consectetur adipiscing
elit. Donec vulputate mi sed nisl blandit sed porttitor massa fringilla.
</div>
</div>
</body>
</html>
The result of this is a pretty little black box with some text and then a sub box with more text and the key item in here is the text wrapped in <small/>.
Is there a way to have anything under a certain div NOT inherit the CSS? Maybe I need to take a completely different approach with this.
Thought? Ideas? Suggestions?
Thanks in advance!
Instead of working directly with tag names, keep two sets of classes ("inner" and "outer") and work with those.
So you can have a div.inner definition, and a div.outer definition, and work on them separately. The inner one would have to explicitly undo the settings outer has, though.
Something like
<div class="outer">
<div class="outer">Some content. <small>Small text.</small></div>
<div class="inner container">
<small>Blah blah blah</small>
More content
</div>
</div>
And in your CSS define whatever you need,
div.outer {
border: 1px solid black;
}
div.outer small {
font: 17pt;
}
div.inner {
border: none;
}
div.inner small {
font: 15pt;
}
div.container {
overflow: auto;
width: 500px;
height: 300px;
}
don't think there is a way to not inherit css. i think the only way is to 'reset' all the styles set on its parents explicitly. see eg http://meyerweb.com/eric/thoughts/2007/05/01/reset-reloaded/ for a list of default properties.
There is, as second notes, no way to inherently prevent the cascade of styles, it's the cascade that defines CSS after all. So you are reduced to using the .inner and .outer approach that Welbog suggested.
So you're reduced to defining your styles for the main document as you normally would. However to override those styles for the same elements under the T&C div you would have to explicitly override/re-style. You could use two stylesheets to retain clarity, but you'd have to remember, in the t_and_c.css to explicitly preface every declaration with the id of the enclosing div, for example:
#t&c p {...}
#t&c a:link,
#t&c a:visited {...}

Resources