I want to stick a div left to another div - css

I am working for this website's responsiveness,
I want to stick the ratings image left to with a bit margin, when the width of the window is 335 it is working on left: 50% but when i increase the width of the window, it doesn't remain stick to what i want, Please suggest me, what should i do ??
Here is my code
<div id="filteredRestBody" class="row filteredRestBody">
<div id="row1" class="row">
<div id="yochina" class="col-sm-4 filterThumbnails" style="background: url('images/yochinathumbbck.jpg')">
<img src="images/bestoffers.png">
<div id="discountImg">
<img src="images/discountimg.png" style="">
<div class="discountNum" title="Discount">15%</div>
</div>
<div id="ratings" title="6/10">
<img src="images/ratingy.png">
<img src="images/ratingy.png">
<img src="images/ratingy.png">
<img src="images/ratingy.png">
<img src="images/ratingy.png">
<img src="images/ratingw.png">
<img src="images/ratingw.png">
<img src="images/ratingw.png">
<img src="images/ratingw.png">
<img src="images/ratingw.png">
</div>
<div id="ratingNum">5</div>
<div id="restaurantThumbnailsTitle" class="restaurantThumbnailsTitle">
<span>Yo! China</span>
<br>
<span class="restaurantThumbnailsTitleText">chilled out chinese</span>
</div>
CSS
.filteredRestBody {
background: none repeat scroll 0 0 rgba(0, 0, 0, 0);
border: medium none;
border-top-left-radius: 23px;
box-shadow: 0 0 0 grey;
height: auto;
margin-left: -4%;
padding: 0 0 47px 8px;
position: relative;
top: 30px;
width: 111%;
}
.filterThumbnails {
background-position: 2px -19px;
background-repeat: repeat;
border-top-left-radius: 10%;
border-top-right-radius: 10%;
height: 200px;
margin-left: 5.3%;
margin-top: 50px;
position: relative;
top: -36px;
width: auto;
}
#ratings {
background: none repeat scroll 0 0 rgba(0, 0, 0, 1);
border-radius: 8px;
left: 50%;
padding: 0 7px 4px;
position: absolute;
top: 49%;
}
#ratingsNum {
background: none repeat scroll 0 0 rgba(0, 193, 0, 0.9);
border-bottom-right-radius: 9px;
border-top-left-radius: 9px;
font-family: Times New Roman;
font-size: 1.6em;
font-weight: bolder;
left: 89%;
padding: 0 8px;
position: absolute;
top: 45.5%;
width: auto;
}
This is the first screenshot when the width is 335
This is what happens when i increase the window's width

Instead of using left, you can use right property in your CSS. This will stick ratingsNum and ratings divs to the right border of container div.
CSS
#ratings {
right:50px;
}
#ratingsNum {
right:10px;
}
jsFiddle Example
Hope it helps.
As a side note, I've noticed that your snippet contains some elements (i.e. #discountImg div) without the closing tag (in this example </div>). Pay attention because this can lead your layout to unpredictable results.

Related

Scroll bar not showing when elements go beyond page view

I am creating a simple recipes app. A list of recipes with there images are shown down the right hand side in individual tiles. The problem I am having is that when the list of recipe tiles goes beyond the browser view, the browser scroll bar does not appear (I have chrome as my browser) and the 3rd recipe tile goes beyond the browser page without being able to scroll down to see the rest of it.
I have found similar questions asked on here and have tried the resolutions provided (such as setting overflow to auto on the container), none of which have resolved my issue.
Here is the relevant code:
h2 {
font-size: 280%;
font-family: 'Lobster', cursive;
left: 160px;
position: relative;
top: 15px;
color: rgb(90, 205, 250);
text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000;
}
* {
background-color: transparent;
width: 265px;
}
img {
border-radius: 12px;
height: 100px !important;
width: 261px;
right: 3px;
position: absolute;
bottom: 76px;
}
.list-item {
display: flex;
top: 0px;
position: relative;
left: 88px;
background-color: white;
border-radius: 12px;
margin-top: 15px;
border: solid #a84605 1.5px;
color: hsl(17, 89%, 40%);
height: 180px;
}
.item-text {
top: 75px;
position: relative;
color: rgb(100, 100, 100);
}
.recipe-container {
height: auto;
overflow: auto;
width: auto;
}
<link href="https://fonts.googleapis.com/css?family=Lobster&display=swap" rel="stylesheet">
<h2>Recipes</h2>
<div class="recipe-container">
<div *ngFor="let recipe of recipes" class="list-item">
<a href="#" class="list-group-item clearfix" (click)="onRecipeSelected(recipe)">
<img [src]="recipe.imagePath" alt="{{ recipe.name }}" class="img-responsive">
<div class="pull-left">
<h4 class="list-group-item-heading item-text">{{ recipe.name }}</h4>
<p class="list-group-item-text item-text">{{ recipe.description }}</p>
</div>
</a>
</div>
</div>
I think the problem is that you set your height to 'auto' in .recipe-container. Try setting a fixed height of max-height. You could use 'vw' unit to set the height or '%'.

Lightbox with flexible width

I'm trying to make a floating menu for one of my projects but I just can't get it to work.
My aim is to be able to have a horizontal menu floating in in the middle of the screen with a content div underneath. The content div (#preferencescontent), should never be wider than the content insider it, but no wider than 90% of the screen.
Now to the problem. It seems to work, sometimes, and for unknown reasons. Some tables shrink the div to the size of the menu while others expands a lot. I've added an example which for some reason expands the div way more than I expect it to.
Here's the code (codepen below):
<div class="lightbox" id="preferencesdiv">
<div id="preferencesholder">
<div class="sidemenu">
<div id="deviceoverviewbutton" class="menuitem">Device overview</div>
<div id="irulesbutton" class="menuitem">Defined iRules</div>
<div id="certificatebutton" class="menuitem">Certificates</div>
<div id="logsbutton" class="menuitem">Logs</div>
<div id="preferencesbutton" class="menuitem">Preferences</div>
<div id="helpbutton" class="menuitem">Help</div>
</div>
<div id="preferencescontent">
<div id="helpcontent">
<h2>Tips and tricks</h2>
<h3>Filtering for pool members being down</h3>
<p>This one is a bit of a hidden feature. In the Pool/Members column you can filter on "DOWN", "UP" and "DISABLED".</p>
<p>It's not perfect though since pools or members with any of these words in the name will also end up as results.</p>
</div>
</div>
</div>
https://codepen.io/anon/pen/vdOXWj
Grateful for any help. Thank you!
You can try removing float from your elements.
Also, you are adding positioning coordinates to elements which have not been given an explicit position, so you can remove them.
codepen
:root {
--alternatetablecolor: #f9f9f9;
--headerbackgroundcolor: #efefef;
--headerfontcolor: #333;
--bordercolor: #dddddd;
--defaultfontcolor: #222;
}
.lightbox {
position: fixed;
left: 0;
top: 0;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.8);
text-align: center;
}
div#preferencesholder {
background: #fff;
display: inline-block;
text-align: left;
max-height: 75%;
max-width: 90%;
overflow: hidden;
padding: 0px;
border: 1px #000 solid;
-webkit-box-shadow: 7px 7px 5px 0px rgba(50, 50, 50, 0.75);
-moz-box-shadow: 7px 7px 5px 0px rgba(50, 50, 50, 0.75);
box-shadow: 7px 7px 5px 0px rgba(50, 50, 50, 0.75);
margin-top: 100px;
}
div#preferencescontent {
overflow-y: scroll;
max-height: 80%;
margin: 10px;
width: 100%;
}
div.sidemenu {
background-color: var(--headerbackgroundcolor);
width: 100%;
text-align: center;
}
div.sidemenu div.menuitem {
padding: 10px;
font-family: "Source Sans Pro", "Helvetica Neue", Helvetica, Arial, sans-serif;
display: inline-block;
margin: 0px -2px 0px -2px;
}
div.sidemenu div.menuitem img {
max-height: 30px;
vertical-align: middle;
}
div.menuitem:hover {
background-color: #d0d0d0;
cursor: pointer;
}
div#helpcontent {
max-width: 550px;
margin: 0 auto;
}
<div class="lightbox" id="preferencesdiv">
<div id="preferencesholder">
<div class="sidemenu">
<div id="deviceoverviewbutton" class="menuitem">Device overview</div>
<div id="irulesbutton" class="menuitem">Defined iRules</div>
<div id="certificatebutton" class="menuitem">Certificates</div>
<div id="logsbutton" class="menuitem">Logs</div>
<div id="preferencesbutton" class="menuitem">Preferences</div>
<div id="helpbutton" class="menuitem">Help</div>
</div>
<div id="preferencescontent">
<div id="helpcontent">
<div id="helpcontent">
<h2>Tips and tricks</h2>
<h3>Filtering for pool members being down</h3>
<p>This one is a bit of a hidden feature. In the Pool/Members column you can filter on "DOWN", "UP" and "DISABLED".</p>
<p>It's not perfect though since pools or members with any of these words in the name will also end up as results.</p>
</div>
</div>
</div>
</div>
If you remove "float:left;"
from "div.sidemenu"
Do you get your desired result? I'm not sure I understand what you are trying to achieve here.

Why does my interscroller format not click?

I built a ad format for my website and it works well but I am unable to click the actual ad element. It seems the layering / positioning I have used to achieve the affect, does not allow my to click the elements that need to be clicked i.e. the actual ad.
Below is the main html that positions the ad with some inline css
<div id="inter-outer" class="interscroller-wrapper" style="height: 667px; right: 14.7031px; width: 375px;">
<div id="intscdiv" class="interscroller-bg-wrapper" style="height: 667px; right: 0px; clip: rect(0px 375px 677px 0px); width: 375px;">
<div id="nxtads" class="interscroller-bg" style="height: 667px; width: 375px; padding: 0px; overflow: hidden; text-align: center;">
<div style="color: rgb(0, 0, 0);font-weight: bold;margin: auto;padding: 0px;text-align: center;font-family: arial;width: 320px;/* display: none; */">ADVERTISEMENT</div>
<div id="smt-130304454" style="margin: 0px auto;width: 320px;height: 480px;/* position: absolute; *//* z-index: 1000000000; */">
<a href="http://google.com">
<img src="https://support.inmobi.com/ui/uploads/Interstitial-1.png" width="320" height="480"/>
</a>
</div>
<div style="color: rgb(0, 0, 0);font-weight: bold;margin: 0px;padding: 0px;text-align: center;font-family: arial;position: fixed;width: 375px;bottom: 20px;/* display: none; */">SCROLL TO CONTINUE</div>
</div>
</div>
</div>
Below is some external css that is included.
.interscroller-wrapper {
position: relative !important;
cursor: pointer !important;
background: #ffffff !important;
z-index:10000000 !important;
}
.interscroller-bg-wrapper {
position: absolute !important;
width: 100% !important;
left:0 !important;
}
.interscroller-bg {
position: fixed !important;
height: 100% !important;
top: 2% !important;
backface-visibility: hidden !important;
-webkit-backface-visibility: hidden !important;
border:0 !important;
}
Here is a js fiddle with demo https://jsfiddle.net/kw80z7cL/
I cant work it out.

How can I display absolute div's beneath each other?

I've created a webpage with multiple flag banners using the class flag and flag-category. Both classes are set to position:absolute to show them uppon the image.
Now I want to display them beneath each other, so that they are in the same horizontal line. I already tried using margin-left / margin-right and float:left, but without success.
Here is the code:
.flag {
position: absolute;
font-size: .7em;
letter-spacing: 1px;
font-weight: 700;
padding: 3px 10px 3px 10px;
color: #FFF;
background-color: #f39;
border-radius: .4em 0 0 .4em;
margin: -25px -50px;
}
<head>
<link rel='stylesheet' id='child-theme-css' href='http://vocaloid.de/wp-content/themes/Vuturize/style.css?ver=2.1.2' type='text/css' media='all' />
</head>
<body class="category">
<div class="site-container">
<div class="site-inner">
<div class="content-sidebar-wrap">
<main class="content">
<article class="entry">
<header class="entry-header">
<div class="flag">Weekly VOCALOID Ranking</div>
<div class="flag flag-category2">Daily Ranking</div>
<div class="flag flag-category2">Events</div>
<div class="flag flag-category2">Interviews</div>
<div class="flag flag-category2">Merchandise</div>
<img src="https://www.dnb.no/portalfront/bilder-dnb/mennesker/680/680-220-bedriftsmoete-3.jpg" class="attachment-post-thumbnail" />
</header>
</article>
</main>
</div>
</div></div>
</body>
Try one with absolute and one relative.
Har du testat med en absolute och en relative?
.flag {
position: absolute;
font-size: .7em;
letter-spacing: 1px;
font-weight: 700;
padding: 3px 10px 3px 10px;
color: #FFF;
background-color: #f39;
border-radius: .4em 0 0 .4em;
margin: -25px -50px;
}
.flag:before {
content: ' ';
position: relative;
top: 0;
border-width: 26px 26px 0 0;
border-style: solid;
border-color: #F39 transparent transparent;
right: -26px;
}
.flag-category2:after {
border-width: 4px;
border-color: #005357 #005357 transparent transparent;
}
Try giving each item a unique class and apply z-index on them so that they stack on top of each other.
Or you could redo the flags as List Items, and apply margin-right to them so that they do not overlap like how they do right now.
Either ways, your divs don't have enough space between each other.

How can I make these CSS absolute positions work in IE?

Please look at the code below. If you look at the diagram of the body, each colour represents different content on the right. However, these links won't work in IE, I assume due to the CSS I have written.
Can anyone shed some light on how I can replicate this in IE?
HTML:
<div id="male">
<img src="male1.png" alt="male1 Compensation Calculator" title="male" width="130" height="300" class="alignleft size-full wp-image-117" /></p>
<div class="head"><span class="whole fakelink"></span></div>
<div class="neck"><span class="whole fakelink"></span></div>
<div class="arm1"><span class="whole fakelink"></span></div>
<div class="arm2"><span class="whole fakelink"></span></div>
<div class="torso"><span class="whole fakelink"></span></div>
<div class="legs"><span class="whole fakelink"></span></div>
</div>
CSS:
div.head {
position: absolute;
width: 70px;
margin-left: 31px;
height: 70px;
}
div.neck {
position: absolute;
height: 6px;
width: 18px;
margin: 70px 0px 0px 56px;
}
div.arm1 {
position: absolute;
height: 105px;
width: 30px;
margin: 77px 0px 0px 100px;
}
div.arm2 {
position: absolute;
height: 105px;
width: 30px;
margin: 77px 0px 0px 0px;
}
div.torso {
position: absolute;
height: 118px;
width: 70px;
margin: 77px 0px 0px 31px;
}
div.legs {
position: absolute;
height: 105px;
width: 69px;
margin: 195px 0px 0px 31px;
}
.whole {
width:100%;
height:100%;
display:block;
}
.fakelink {
color:white;
font-weight:bold;
}
.fakelink:hover {
cursor: pointer;
text-decoration:none;
}
I know of only two solutions to fix this issue, though they both ultimately come down to needing a background:
Option 1
Set a background-color on .fakelink that is not transparent. Whilst clearly in your case this wouldn't be very helpful it will illustrate the need for a background.
If you were only needing to support IE9, I would suggest using rgba with a low alpha opacity:
.fakelink{ background-colour: rgba(255,255,255,0.01) }
Option 2
Use a small transparent .png or .gif and tile it as the background-image for .fakelink

Resources