Content won't stay inside div - css

Hope I don't seem like too much of a newbie developer with this problem but I can't for the life of me seem to find the right combination of techniques to get this to work. Essentially, when in mobile view I have a div that populates with image data once searched and when that happens all of my menu icons get pushed somewhere else instead of staying put. Shouldn't the image data be confined to the div? I've tried position absolute, position fixed, overflow:hidden, hard coding the height in pixels, using flex-wrap and other flex properties, among other things. Nothing has worked so far. Check it out here: https://craftyquotes-bja.herokuapp.com/ Click on the camera button, search for any image genre and see what happens. That's the issue. Any hints or pointers in the right direction would be appreciated!

You have a class "pic-render "inside" pic-render", I do not know why, but in my opinion it is not necessary. Add a pair of properties to the nested div tags.
<style>
.form_container {
height: 5vh;
overflow: hidden;
}
.image_container {
height: 63vh;
overflow: auto;
}
</style>
<div class="pic-render">
<div class="form_container">
<form>
<input type="text" autocomplete="off" name="searchValue" placeholder="Search Images">
<button>SEARCH</button>
</form>
</div>
<div class="image_container">
<img src="">
...
<img src="">
</div>
</div>

Related

How to align span to stick to a div on the same line?

Introduction
My question is quite specific and I tried a lot of solutions from SO, but they don't work, because my problem is related to accessing dynamically generated DOM.
I have the following generated HTML (can't change anything in it, except the CSS):
<div style="flex: 1; z-index: 2;">
<input type="text" />
</div>
<span style="display: none">X</span>
<span>A</span>
The 'A' in the span generates arrow icon for select/drop box. But the span goes below the div with the input.
The question:
I want to align the second span (the first has display: none, so probably not a problem) to stick to the div. I don't have access to the dynamically generated HTML, but I kinda have access to the CSS (using ::ng-deep to access the generated html with Angular 9).
How to align the span to stick with the div?
What I've already tried, but didn't work:
I added float: right to the span and it works, but it's on a new line.
I changed the div to be display: inline-block, but it doesn't work. I tried to make the div and the span overflow: hidden; white-space: nowrap, but still no success.
I would appreciate any tips to try to achieve this.
Wrap the whole tags with div, and give display: flex.
It will be like this.
<div class="wrapper">
<div style="flex: 1; z-index: 2;">
<input type="text" />
</div>
<span style="display: none">X</span>
<span>A</span>
</div>
In this code, wrapper class has display: flex.
This attribute set all inside tags in one line because flex-direction is row.(default)

twitter bootstrap - is it possible to undo "container" margins

my html looks like this:
<div class="container">
<div class="header-content">
hello!
</div>
</div>
i've recently come into a situation where I need the 'header' to be 100% the window for a full-width background. usually i would do this css:
<div class="header-background-color">
<div class="container">
<div class="header-content">
hi!
</div>
</div>
</div>
unfortunately, i am fairly deep into a framework and can't wrap the container. i need to construct it within the container.
<div class="container">
<div class="header-background-color">
<div class="container">
<div class="header-content">
hi!
</div>
</div>
</div>
</div>
i can't figure out a way to accomplish this, and am wondering if this is possible.
if i use this css for header-background-color
background: blue;
left:0;
position: absolute;
width: 100%;
the element looks right, but the page flow is interrupted.
does anyone know if my target goal is reachable?
i made a bootply to illustrate this http://www.bootply.com/129060
You can use a child (>) selector to select the first container element and set its width to 100% and remove the padding.
.example-3 > .container {
width: 100%;
padding: 0;
}
This assumes you'll always have a wrapper around it with a unique class name (or use body if it's the first div), but this also allows you to remove the position: absolute which is causing the overlap and the height can stay dynamic.
See forked bootply: http://www.bootply.com/129065
I've added a button that inserts a paragraph into the div so you can see how it's not affected by changes in height.
Only thing I can think of is using a dumby element to maintain the vertical space (i.e. set the height), and then use absolute positioning on the full width content (as you mention). This is really ugly and won't be a good solution if the height of the content is dynamic.
See #content_dumby element in forked bootply: http://www.bootply.com/129063

CSS: floats "crashing" in "random" intervals

I have created a site which has little buttons for login and logout at the top right corner.
Inside a "header_content" div I have got another div with "float: right" (to keep it at top right corner) and inside that div I have li with link and a form with button. One has float: right and another float: left (to keep them in line).
Usually everything works fine, but for some strange reason sometimes the floats crashes and the second link "falls" through. After refreshing page everything goes to normal, untill again the crash occurs (it is not really that frequent, but still annoying though)
So is this browser based problem (I am using Chrome), or is it because I have to many "nested" floats or something else?
EDIT:
I guess I have little more floats that I thought :D
Here is the code, hope you'll get the picture ... (the one who keeps falling down is the form with button and id=right)
<div id="header">
<div id="header_banner">
.... smt
</div>
<div id="header_content">
<div id="outer_left">
..... smt
</div>
<div id="outer_right">
<li>
<a id="left" href="........."></a>
<form id="right" method="post" action="">
<div>
......
<button type="submit" value="value"></button>
</div>
</form>
</li>
</div>
</div>
</div>
#header_banner, #outer_left, #left {
float: left;
.....
}
#outer_right, #outer_right li, #right {
float: right;
.....
}
With out an example, I suggest you float left the two links that you are trying to "keep in line". Make sure their widths combined with padding and margines do not exceed the wrapping element's width.
Your floats are arguing with eachother. If you want the elements to be "in line" you could do something with "display: inline-block"
div.right
{
white-space: nowrap;
}
div.right ul li
{
display: inline-block;
}
Well, if the display changes for reload to reload, is there the possibility that the content changes? Even a invisible space character or a border can take up too much space so that the container is too small to float them in line.
Have you tried to enlargen the container by say 50px and test if the behaviour continues?

img vertical align is not working inside a colorbox

I've used the line-height property in the parent and the vertical-align in the child:
<div style="height:500px; line-height:500px">
<img src="someimage.jpg" style="vertical-align:middle" />
</div>
It Works inside the body tag but when I try to put that content inside a colorbox the image aligns to the top, Is there some restriction of this rule inside absolute positioned elements, floated elements or something???
If anyone knows a better way to center an image vertically (not with top:50%) I'd appreciate it
Thanks
You can use display: table-cell but you will have to put another div wrapping the image at this way:
<div style="display: table-row; height: 500px;">
<div style="display: table-cell; vertical-align: middle;">
<img src="someimage.jpg"/>
</div>
</div>
After comparing every single style (computed and not) I deleted de colobox css but it didn't solve the problem so I think it should be something related whith the HTML. At the end I changed the DOCTYPE from transitional to RDFa and it worked!!

CSS z-index broken in IE7

I'm aware of the z-index problem in IE7, but I have a strange situation here, and none of the fixes suggested online seem to work. I've got a list of items, each one has a pop-up bubble div inside the "li" tag, like so:
<div class="inner">
<ul>
<li onmouseover="bubbleOn(5661)" onmouseout="bubbleOff(5661)" id="c5661">
<img src="/images/new/simple-dot-brown.gif" class="coloredDot" />
Asthma,
<small id="year5661">1974</small>
<div class="mouseover-bubble orange" id="bubble_5661" style="display:none;">
<h6>Asthma</h6>
<div class="definition">
<p>A form of bronchial disorder....</p>
</div>
</div>
</li>
</ul>
</div>
Here is the relevant CSS:
div.mouseover-bubble {
position: absolute;
width: 360px;
left: 10px;
bottom: 10px;
z-index: 10000;
}
As long as I leave the CSS the way I received it, the pop-up works fine. But I've been asked to move the popup divs below the matching "li", instead of above it. If I change the line "bottom: 10px" to "top: 10px", then suddenly in IE7 the z-index fails and I can see the information that should be hidden underneath the pop-up div. Anyone have ideas why this would happen? Most of the IE7 z-index stuff I find talks about positioning, but I'm not changing the CSS positioning, just switching "bottom" to "top".
i got the same problem this moorning... you'll have to put the element in position:relative
Another way to do it is to set the parent's z-index to something higher...
dont ask me why... but it works
EDIT sorry.. i've just seen that you cant change the position to relative.. try the second option and let me know it that works

Resources