Bootstrap: Create images on same row - html

I want to create a list item in a game that has a background, an iconholder with an icon inside it, a title and description and up to three resources. I am working with Bootstrap and thought that using a container-fluid with a row inside it might work but the images are placed underneath each other (see image) []
I don't want to use things like position:absolute, or set the margin at like -250% 0 0 0. Is there a way to say that images should be placed on top of one another, instead of underneath each other?
This is my HTML code thus far:
.resourceHolder
{
position: relative;
}
.resourceIcon
{
position: relative;
}
.nopadding
{
padding: 0 !important;
margin: 0 !important;
}
.iconHolder
{
position: relative;
width: 100%;
}
.icon
{
position: relative;
width: 65%;
}
.bannerText
{
font-family: FenwickWood;
color: #0062cc;
margin: 0 0 20% 0;
-webkit-text-stroke-width: 1px;
-webkit-text-stroke-color: beige;
pointer-events: none;
}
<div class="container-fluid">
<img class="background" src="assets/UI/window/wood_plank1.svg">
<div class="row">
<div class="col-sm-3 nopadding">
<img class="iconHolder" src="assets/UI/window/grid4L.svg">
<img class="icon" src="assets/Terrain_Medieval/Decor/villageSmall03.png">
</div>
<div class="col-sm-3 nopadding">
<h1 class="bannerText">Village</h1>
</div>
<div class="col-sm-2 nopadding">
<img class="resourceHolder" src="assets/UI/window/grid4L.svg">
<img class="resourceIcon" src="assets/Icons/gold_coins.png">
</div>
</div>
</div>

You can use CSS Grid layout, and put both images in the same cell.
Checkout out this jsfiddle: https://jsfiddle.net/dscmr7oz/.
Also, when you say you don't want to use things like position:absolute", why is that? It is a completely legitimate way to put things on top of each other. Are you aware that if you put an absolute-positioned element inside a relative-positioned element, that the inner element is absolutely positioned, relative to its parent?
.container {
position: relative;
}
.container .bottom-image {
position: absolute;
top: 0;
left: 0;
z-index: 1;
{
.container .top-image {
position: absolute;
top: 20px;
left: 20px;
z-index: 2
}

Related

How to place an image on top of text?

the top attribute appears not to be working on a html. I am trying to use the top attribute on image to move an image to the top and place above a text but the top attribute of a css never moves the image Here is snippet
<div class="stl_02">
<div class="stl_03">
<img src=""
alt=""style="top: 4.4538em;" class="stl_04">
</div>
<div class="stl_view">
<div class="stl_05 stl_06">
//other texts here
here are the css rules
.stl_02 {
height: 46em;
font-size: 1em;
margin: 0em;
line-height: 0.0em;
display: block;
border-style: none;
width: 51em;
}
.stl_03 {
position: relative;
}
.stl_04 {
width: 100%;
clip: rect(-0.041667em,51.04167em,66.04166em,-0.041667em);
position: absolute;
pointer-events: none;
}
Please how can push the image to the top using this attribute style="top: 4.4538em;" is a challenge
Your element does have the top attribute applied. This can be seen in the following:
.stl_02 {
height: 46em;
font-size: 1em;
margin: 0em;
line-height: 0.0em;
display: block;
border-style: none;
width: 51em;
}
.stl_03 {
position: relative;
}
.stl_04 {
width: 100%;
clip: rect(-0.041667em, 51.04167em, 66.04166em, -0.041667em);
position: absolute;
pointer-events: none;
}
<div class="stl_02">
<div class="stl_03">
<img src="http://placehold.it/100" alt="" style="top: 4.4538em;" class="stl_04">
</div>
<div class="stl_view">
<div class="stl_05 stl_06">
</div>
</div>
</div>
If you are not seeing this effect, it is possible you have a rule with higher specificity overriding it, or you have cached the style before you applied this rule.
It's also worth noting that top only works on a positioned element. You need to have position: relative, position: absolute or similar on .stl-04 in order to position it with top.
Alternatively, you may be looking for margin-top, which positions vertically based on the containing element.
As an aside, basing margins off of font sizes (with em units) is generally bad practice; you should really use fixed units instead (preferably not going to so many decimal places).

Bootstrap row background image becomes wider than parent grid width

I am using bootstrap, I wanted one div behind the other div, so used z-index en position: absolute and relative.
When doing this, every div under the div with z-index: 1 goes behind this div, while I want it to stay under it.
The div also becomes wider than the max-width when using 100%
<div class="row" id="MENUROW">
<div class="col-md-12" id="MENUCOLUMN"><h1>SHOP</h1></div>
</div>
<div class="row" id="MAINROW"> <!-- this has the background-image -->
<div class="col-md-12" id="MAINCOLUMN">
</div>
</div>
CSS:
#MENUROW
{
position: relative;
height: 80px;
background-color: transparent;
z-index: 2;
}
#MAINROW
{
position: absolute;
z-index: 1;
top: 60px; /*because there is 1 div above the menu div, this div needs to be just under that div, behind the menu div */
width: 100%;
background-image: url(../images/background.jpg);
background-size: cover;
}
when doing this the background image goes wider (to the right) than the width of the parent div.
https://jsfiddle.net/2cs60vrr/3/ example, just made the background red to show how wide it should be, the background image goes much wider
Point 1
You didn't used .container class in your HTML. Bootstrap has a structure to get it's maximum feature. You must need to use .container. Bootstrap structure is below:
<div class="container">
<div class="row">
<div class="col-*-*">
Your Content
</div>
</div>
</div>
Make your html as above to solve this issue.
Point 2
If you want not change your html, then use this code below to any .row to solve this issue.
margin-left:0;
margin-right:0;
I am sorry if we are unsure what you are looking for but is that what you want?
.grid {
margin: 0 auto;
max-width: 100%;
width: 100%;
background-color: #fff;
}
.row {
width: 100%;
margin-bottom: 0px;
display: flex;
}
#MENUROW {
position: absolute;
height: 80px;
background-color: red;
z-index: 2;
}
#MAINROW {
position: absolute;
z-index: 1;
top: 0;
width: 100%;
max-width: 1400px;
background-image: url(https://upload.wikimedia.org/wikipedia/commons/e/ed/Palais_Garnier.jpg);
background-size: cover;
}
https://jsfiddle.net/norcaljohnny/xt9c9d2r/2/
You should put the wrapper around the whole thing to position:relative;
And both rows to position:absolute;
That's it.
When using position:absolute; the block goes to the absolute top left corner of the closest parent html tag that has a position:relative;. If there is no parent with position:relative; your absolute positioned items go to the upper left corner of your screen.
(the first row is not a parent of the second, but they are siblings. The wrapper "grid" is the parent of the 2 rows)
<div class="grid">
<div class="row" id="MENUROW">
<div class="col-md-12" id="MENUCOLUMN">
<h1>SHOP</h1>
</div>
</div>
<div class="row" id="MAINROW">
<div class="col-md-12" id="MAINCOLUMN">
text
</div>
</div>
</div>
And CSS
.grid {
position: relative;
}
.row {
width: 100%;
}
#MENUROW {
position: absolute;
background-color: red;
z-index: 1;
}
#MAINROW {
position: absolute;
z-index: 2;
background-image: url(https://upload.wikimedia.org/wikipedia/commons/e/ed/Palais_Garnier.jpg);
background-size: cover;
}
Here is your updated example:
https://jsfiddle.net/2cs60vrr/6/

Push ribbon div to right edge of screen

I am designing a site that has a specific requirement to display a ribbon to the far right of the screen, I am using Bootstrap and the ribbon is in a bootstrap container, with a row and columns divided equally between the two elements, I want the Designer Text to stay exactly where it is because I am trying to keep it responsive and contained when going to mobile. How can I push the image div (Ribbon) all the way to the far right extending outside of the container.
I have include an image below of what I am working with. I may be doing this completely wrong, as my design skills are minimal.
I would like it to look like this
Here is the code:
.bookmarkRibbon {
/*width:100%;*/
height: 0;
width: 100%;
border-bottom: 22px solid #ff5750;
border-top: 22px solid #ff5750;
border-left: 20px solid transparent;
position: absolute;
margin-right: -3000px;
}
.bookmarkRibbon a {
display: block;
padding: 0;
position: relative;
/* allows us to position our pseudo-elements properly */
background: #ff5750;
overflow: visible;
/*height: -18px;*/
margin-left: 29px;
margin-top: -18px;
color: #fff;
text-decoration: none;
font-weight: bold;
font-size: x-large;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container">
<div class="row">
<div class="col-xs-7">
<h1 ID="lblCategoryName" runat="server"></h1>
</div>
<div class="col-xs-5">
<div class="bookmarkRibbon" id="discountBannerContainer" runat="server" style="margin-top: 15px">
20% OFF ADDRESS STAMPS<p class="mine">CODE: STAMP 20</p>
</div>
</div>
</div>
</div>
You have to move the ribbon outside the container to be child of body.
Than you can position it absolute.
<body>
<div class="ribbon"></div>
</body
.ribbon {
position: absolute;
top: 300px;
right: 0;
}
If you can not move the ribbon outside the container you have to use position fixed.
Unfortunately the ribbon will scroll with your page.
.ribbon {
position: fixed;
top: 300px;
right: 0;
}
Last option would be to use negative values and use the calc function.
This is not quite ease but doable.
Do you have a link to your site? I could take a looke at it if you like to.

Responsive, pure CSS hover image gallery

I want to make responsive image gallery. That will display extended image on thumbnail hover. Gallery can't use any JS this is requirement.
But there is 1 little problem. Gallery needs to be responsive.
That means expanded image have to be the same size as the default image that is responsive and resize on smaller devices.
Here is my html code
<div class="container"></div>
<div class="container">
<div id="gallery-photo-container">
<img src="http://imgur.com/60BBDre.jpg">
<div class="gallery-thumbnail-image">
<img src="http://imgur.com/60BBDre.jpg">
<div class="gallery-main-image">
<img src="http://imgur.com/60BBDre.jpg">
</div>
</div>
<div class="gallery-thumbnail-image">
<img src="http://i.imgur.com/C7SFJxy.jpg">
<div class="gallery-main-image">
<img src="http://i.imgur.com/C7SFJxy.jpg">
</div>
</div>
<div class="gallery-thumbnail-image">
<img src="http://i.imgur.com/aa5kiAi.jpg">
<div class="gallery-main-image">
<img src="http://i.imgur.com/aa5kiAi.jpg">
</div>
</div>
<div class="gallery-thumbnail-image">
<img src="http://imgur.com/TWLJOVv.jpg">
<div class="gallery-main-image">
<img src="http://imgur.com/TWLJOVv.jpg">
</div>
</div>
</div>
</div>
Absolute approach
I have almost done it, using absolute position and positioning with top attribute. But on resize expanded image is the size of left container beginning to the right end of the page.
Here is my DEMO1 and CSS.
.gallery-thumbnail-image:hover > .gallery-main-image {
visibility: visible;
opacity: 1;
}
.gallery-thumbnail-image {
display: inline-block;
}
#gallery-photo-container .gallery-thumbnail-image > img {
width: 79px;
}
#gallery-photo-container img {
max-width: 100%;
}
.gallery-main-image {
position: absolute;
visibility: hidden;
top: 18px;
left: 18px;
margin-right: 8px;
}
.container {
width: 50%;
}
#gallery-photo-container {
border: 1px solid black;
padding: 10px;
}
Relative approach
I think it can be done it too, by using relative position and positioning with bottom attribute. But here the problem is that thumbnail image container is resizing to the expanded image size on hover. And the bottom attribute value is screen size dependent.
In this DEMO2 you have to click on a thumbnail because they are jumping. And here is CSS for relative approach.
.gallery-thumbnail-image:hover > .gallery-main-image {
display: block;
opacity: 1;
}
.gallery-thumbnail-image {
display: inline-block;
}
#gallery-photo-container .gallery-thumbnail-image > img {
width: 79px;
}
#gallery-photo-container img {
width: 100%;
}
.gallery-main-image {
position: relative;
display: none;
bottom: 373px;
}
So, could it be done responsive way with one of these two approaches? Or maybe you have another idea. I'm looking forward for your help.
See this update of your plunk.
https://plnkr.co/edit/6EOKiKEQcxDiuIXApPLo?p=preview
the main changes are here:
.gallery-main-image {
position: absolute;
display: none;
top: 10px;
left: 10px;
right: 10px;
}
#gallery-photo-container {
border: 1px solid black;
padding: 10px;
position: relative;
}
Use of an absolute element positioned within relatively positioned element.
You need a margin-right: 8px;, because of the top: 8px; left: 8px; Plunkr:
.gallery-thumbnail-image:hover > .gallery-main-image {
visibility: visible;
opacity: 1;
margin-right: 8px;
}
Slightly off-topic, but... just in case you're interested in simulating an onclick event with CSS, see this SO answer.

CSS - Positioning Conundrum

I'm working with absolute positioning within a relative div. The code is as such: http://jsfiddle.net/32mq5v6L/1/
HTML
<div id="container">
<div id="featured-posts">
<div class="slide"><img src="http://alien.devprose.com/starwars/wp-content/uploads/2014/12/star-wars-droid.jpg" /></div>
<div class="slide"><img src="http://alien.devprose.com/starwars/wp-content/uploads/2014/12/han-solo-1140x350.jpg" /></div>
</div>
<div id="other-content">
Other Content
</div>
</div>
CSS
#container { width: 100%; margin: 0 auto; background: #eee; }
#featured-posts { position: relative; width: 100%; height: auto;}
.slide { width: 100%; height: 20px; position: absolute; top: 0; }
#other-content { }
My problem is the other-content div appears underneath #featured-posts unless I apply a set height to that container, which I can't do since the goal is to make all of this responsive.
Where am I going wrong?
If you plan to have #other-content after positioned container, you will have to create new stacking context in order to move it above. One way to do it since it's not positioned is to set very little opacity:
#other-content {
z-index: 10;
opacity: .99;
}
Demo: http://jsfiddle.net/32mq5v6L/1/