i have paragraphs with text and a div what say something like "more" like this:
<div>
<p>
Lorem ipsum dolor sit ametm.
</p>
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod.
</p>
<div class="extra">more</div>
</div>
I need to place the extra div right behind the end of the last word in the paragraph, on the same line.
like this: this is the end of p - more
It seems to be easy to do this with a p:after selector but i cant use this because i need to work with the "extra" div in jquery.
And I need to have the paragraph using display or display-inline.
Do somebody has a tip?
thanks alot!
edit: I need to have the extra-div next to - not wrapped in - the p
thats is the problem
and i tried to use span and inside-block but without any luck
Try this:
<div>
<p>Lorem ipsum dolor sit ametm.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod.
<span class="extra">more</span>
</p>
</div>
Can you use display: inline-block on the div?
That lets the element have width, height (and other box properties like padding), but behave like a character in a paragraph when it comes to positioning.
Oh also, you probably have to place the div within the last paragraph since otherwise, the paragraph will push it down - the paragraph has its own box in the page.
i cant wrap the span inside the p because the p is coming from a wordpress loop.
at the end i used jquery to append the span at the end of the last p.
$(document).ready(function() {
$('.extra_available p:last-of-type').append(' <span class="extra"> extra </span>');
});
thanks alot!
Related
I am trying to move a button in the middle of the left screen but when I change anything the entire things move. like for example, I am using cards when I move the button down the cards move too which I don't want.
Sandbox link : click here
I just want to display a button with expanding effect when hover over it, but it should stick to the left side of the UI and in the middle.
Current:
Expected:
Demo: https://codesandbox.io/s/muddy-cache-nwl0c?file=/App.vue
I added the expandable button for you and placed it where you wanted without moving it in the html. I did this by adjusting its margin-bottom.
For the animation on hover for the button I used the css property transition which you can read about a little here if you are interested in learning more. I also added the id of runAll to the button.
Code:
<style>
#runAll {
width: 100px;
transition: width 0.2s ease-in;
}
#runAll:hover {
width: 500px;
}
</style>
<template>
<div>
<b-button id="runAll" class="runAll" style="margin-bottom: -425px">Run All</b-button>
<b-card-group deck>
<b-card border-variant="info" header="Info" align="center">
<b-card-text>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</b-card-text>
</b-card>
<b-card
border-variant="warning"
header="Warning"
header-bg-variant="transparent"
align="center"
>
<b-card-text>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</b-card-text>
</b-card>
<b-card
border-variant="danger"
header="Danger"
header-border-variant="danger"
header-text-variant="danger"
align="center"
>
<b-card-text>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</b-card-text>
</b-card>
</b-card-group>
</div>
</template>
<script>
export default {};
</script>
I would like to set the space between span lines to 15px but it doesn't work when i'm using line-height and i measuring the space with chrome extension the space it's not equal to 15px.
<div class="test">
<span style="line-height:15px;">
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor
</span>
</div>
result:
enter image description here
Is this what you were looking for. I have added a p element so CSS would recognize this block of text.
<div class="test">
<span>
<p style="line-height:25px;">
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor
</p>
</span>
</div>
Your code seems to be working. Remember that line-height doesn't affect the font-size but the effective spacing before and after the text (which is why the DOM viewer in chrome shows that the height hasn't changed).
Here is a snippet to highlight what is going on.
.test {
background-color: blue;
}
.test > span {
line-height: 125px;
color: white;
}
<div class="test">
<span>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor
</span>
</div>
your code is working . you just probably are measure wrong.
<div class="test" style='width:50px'>
<span style="line-height:1; font-size:15px">
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor
</span>
</div>
line-height will take values without units as a multiple of the font size.
it is the space each line takes .
Line boxes "belong" to the containing block element - in your case the .test element, and inline elements like your span are broken into multiple inline boxes across the line breaks and the parts are then fitted into the line boxes.
So on each line of the .test element, there's a zero-width inline box called a strut and a part of the span. The span has a line-height of 15px, but the strut has a line-height determined by the .test element.
Since you're not change the font family, or font sizes, or vertical alignments, the distance from the top of one line to the next is simply the maximum of the line height of the strut and the line height of the span.
The default font size, font-family, and line-heights will give a line height of the strut to be around 18 to 19 pixels, hence why you are seeing bigger gaps than you expect.
So to reduce the space between the lines, reduce the strut's line-height as well as the span's line-height, which you do by setting the line-height for the containing block. The span element can then just inherit it. i.e. Use:
body { width:200px; } /* for demo to make multiple lines */
.test {
line-height: 15px;
}
<div class="test">
<span>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor
</span>
</div>
I have a 3-column layout.
All columns are defined as divs. And they are all implementing the same css:
.div-column {
display:inline-block;
vertical-align: top;
}
As long as the content of the columns is not too wide, they stay beside each other as expected. The last column however contains a div with some text. If this text gets too long, the whole column breaks out of line.
<div id=column3 class=div-column>
<div>
Lorem ipsum dolor sit amet, consetetur sadipscing elitr.
</div>
</div>
I expected the text to wrap if it does not fit in one line. What can I do to make sure the the length of that text does not matter? In other words: How can I make sure that the 3-column layout does not break?
Important: I MUST NOT work with fixed widths (width, min-width, max-width) for the columns!!!
Thanks so much for (hopefully simple) ideas!
If I am not wrong, you want all the three divs to exist at the same place and not to scroll down. For that you have to add a display:table-cell; to the div-column class.
Here is the Working Solution.
The HTML:
<div id=column3 class=div-column>
<div>
Lorem ipsum dolor sit amet, consetetur sadipscing elitr.
</div>
</div>
<div class=div-column>
<div>
Lorem ipsum dolor sit amet, consetetur sadipscing elitr.
</div>
</div>
<div class=div-column>
<div>
Lorem ipsum dolor sit amet, consetetur sadipscing elitr.
</div>
</div>
The CSS:
.div-column {
display:table-cell;
vertical-align: top;
}
Hope this Helps.
how about max-width? that still allows the div to be smaller but when it reaches the specified with it doesn't grow bigger.
max-width:250px;
The JsFiddle
When I add the 36px "Announcement" text to the <div> below, it adds a ton of padding around just the text that is 36px and I cannot get rid of it. I did some research and tried changing the padding of the <div> and the <body> in my stylesheet, but that did not get rid of the padding. Can somebody please explain how to remove the excess padding that is around just the 36px text?
<div style="float:right; width:697px; height:90px; position:relative; top:-50px;">
<p style="text-align:center; font-size:36px;">Announcements</p>
<br/>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam eget.</p>
</div>
Try to explicitely set the line-height CSS attribute, also make sure you set margin to 0.
I have a padded DIV (containing other/sub-DIVs and a DL) followed by some text:
<div> # the padded/main div
<div>
<div>
</div>
</div>
<div>
<dl>
<dt></dt><dd></dd>
<dt></dt><dd></dd>
</dl>
</div>
</div>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec dapibus ante dui, et venenatis enim. Aliquam in massa...
How come there appears no padding at the bottom of the main DIV?
(There is no padding space between the main div's content and the following text.)
Thanks for any help with this!
Tom
You are confusing padding with margin. margin is the property that would define space between the main div and the bottom text.
In your example, it appears that you are trying to use a newline to cause spaceing within html. This will not work. As stated in previous answers, you must set the css margin-bottom property to cause spaec to appear after the bootom of a div and the start of the next HTML element
If you want to use padding and not margin then change to add some way to identify the outer div (I used an ID):
<div id="outerdiv"> # the padded/main div
<div>
<div>
</div>
</div>
<div>
<dl>
<dt></dt><dd></dd>
<dt></dt><dd></dd>
</dl>
</div>
</div>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec dapibus ante dui, et venenatis enim. Aliquam in massa...
and add CSS such as:
#outerdiv
{
padding-top: 1em;
padding-bottom: 1em;
}
EDIT: see it a work here: http://jsfiddle.net/yvaPG/
Thanks for your quick hints!
I was finally able to track the problem down:
The
<dd></dd>
element had a "float:left;". This apparently caused the following text to move "left/up".
My solution:
I inserted an empty
<div></div>
with a "clear:both;" between the dd element and the following text.
If anybody has a more elegant solution, I'd still be interested!
Tom a more reasonable approach would have been to define a seperate CSS class of;
.clearfix {clear:both; display:block;}
This would then allow you to call this div should you require it in other places throughout the page. Simply replace the with to ensure this change continues throughout and isn't reset by the removal of a CSS reset throughout the rest of the page/setup
Regards