Moving elements in inline-block divs moves elements in opposite div [duplicate] - html

This question already has answers here:
My inline-block elements are not lining up properly
(5 answers)
Closed 7 years ago.
I have 3 input fields and one of them I want a caption to go under. I have the input fields inside their own div and each divs are set to inline-block. As of now the middle input box raises higher than the left and right ones because of the caption below it. I am trying to push the input box down a little, but the other input boxes keep moving down with it, even though they're inside their own divs. I usually would do this with a table, but I am trying to understand divs more and positioning them.
Can someone please point me in the right direction?
I tried putting a child div in each and the input in each child div, and then setting the child div relative to the parent div, but it keep behaving the same way - each time I give a margin-top on either the div or the input field the other input fields move too, and nothing (that I know of) is set to make this happen other than defaulted this way.

Use:
vertical-align: top;
Fiddle:
https://jsfiddle.net/ot2ojahb/
If you want to move them all down, add a padding-top to the div

Related

Why does displaying my divs as inline cause them to overlap my h1? [duplicate]

This question already has answers here:
Padding for Inline Elements
(3 answers)
Closed 2 years ago.
I'm just playing around with the border/content box CSS properties in the very early stages of learning.
Trying to make the two boxes line up next to one another- I've achieved it with using the float left and right properties.
However, when I use display inline, it causes an overlap with the above block element h1. I've displayed it as a table here, so the background colour I've set on it only spans the width of the content, but that shouldn't change the fact that it is still a block element.
More than the overlap, display: inline on the div causes the boxes to shrink in size as well.
Can anyone explain why this is happening?
Please see the code here: https://jsfiddle.net/gouvrze1/
Only block elements respect width and height rules. Inline elements just flow with their text content. The overlap is caused by the padding and the fact that the divs are further down in the DOM, so they're drawn after and on top of previous elements.
Try changing your divs to display: inline-block instead.

Trying to understand float and text [duplicate]

This question already has answers here:
Does width property affects clear?
(1 answer)
Why is text wrapping around a floating element instead of going belows like another div?
(1 answer)
floating elements behavior
(2 answers)
Closed 4 years ago.
I'm trying to understand how float works with different elements. The first example have 2 <div> which is floated to left with one of the div having some text. As expected, both are placed next to each other horizontally.
Example 1
The second example have the same setup except that the last <div> with text is not floated to left. Now, I was expecting that <div> to go underneath the first floated <div>. But, the result is different. The second <div> went beneath the first <div> but the text is placed under the first <div>.
Example 2
Can anyone explain me what's happening?
Because overflow happens for yellow div and default is overflow: visible, text inside the yellow div creates a new block formatting context.
Overflow docs
Block formatting context

Make span tag fill the remaining height of div [duplicate]

This question already has answers here:
How to make div occupy remaining height?
(11 answers)
Closed 5 years ago.
I have the following situation:
In a bootstrap row with 2 columns:
- first column with a table that has a button to add new rows
- second column with a label and a span (it does not have to be a span)
The two columns have the same height, but I want the label and the span to fill the column. The label has a fixed height and the span should have the remaining height.
I tried using height: 100%, add an intermediate div, but with no success
Can this be achieved?
Edit: Here is what I would like:
<div>
<label>Descriere</label>
<span class="editorWidth positionDescription">This text is variable
This control should expand as the div in left
Also it should support scrolling if the text is greater than the allocated space
Extra
Extra
Extra</span>
http://jsbin.com/niyenudufo/edit?html,css,output
The span.positionDescription should fill the rest of the div.
I tried to convert the span to div but the scroll of the div is created outside of the containing div
Seeing your actual HTML and CSS it would be alot easier to understand the question however i believe your problem could be resolved with the calc function in CSS:
element {height calc(100% - x);}
x being the height of the logo.
calc is pretty self explanatory and allows basic caluclation in CSS.
this should take up 100% but not overflow. also ensure you account for padding and margin on both elements.

Multiple lines of text, should be width auto but instead is 100% [duplicate]

This question already has answers here:
Make container shrink-to-fit child elements as they wrap
(4 answers)
Closed 6 years ago.
Firstly, apologies for the hard to understand question title.
In HTML/CSS, I want my multiple line text element to inherit it's width from the text inside. It does this if the contained text only spans one line, but when the text spans multiple lines, it forces itself to width:100%;.
Here's a fiddle of the problem: https://jsfiddle.net/guzvpe2q/
This is what happens:
This is what should happen:
Thanks in advance.
The div really is being pushed that wide by the text, but the text cannot fit so it needs to be pushed down a line.
You also need display:inline-block.
One way around it would be to add manual line-breaks after the first word (not exactly ideal i know)
See (https://www.w3.org/TR/CSS21/visudet.html#inlineblock-width)

Align right and push paragraph outside of the div layer [duplicate]

This question already has answers here:
Move onmouseover images to the left?
(2 answers)
Closed 5 years ago.
Here is my page: http://www.ostmoconstruction.com/portfolio.php
If I hover over the first image in each row, the resulting image is the full size of the div and therefore, pushes the second image outside of visibility.
I would like the same thing to happen when I hover over the second image. Perhaps it would push the first image outside the left side of the div layer and display only the second image. I tried setting the positioning to absolute onhover and left: 0; and this seemed to work, but also seemed unstable and left the title of the first image in tact (sometimes conflicting with the title of the second).
Any ideas?
I have the one solution Conflicting Title you can try :
p a {
background:#FFFFFF;
}
I ended up making the image's position absolute and wrapping it in a relatively positioned div layer then gave both negative left margins to align then correctly. The absolute positioning allowed my to bring it to the left and the relative positioning allowed my to push the other image outside of the container div. More info here: Move onmouseover images to the left?