Scroll bar not showing when elements go beyond page view - css

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 '%'.

Related

keep button in div positioned along with parent div

I have the following:
https://codepen.io/anon/pen/KXYLrq
<header>
<input type="text" id="textfield" placeholder="Get it done!" autofocus>
<button id="add"><i class="fa fa-plus" aria-hidden="true"></i></button>
</header>
with css that is too long to list. I'd like to focus on the #media query. Due to larger screen sizes i need to limit the width of the input bar. If i set a max-width, or fixed width the button will move along with the screen size and continually move to the right.
How do i fix the button in one position past a certain screen size ? (In codepen, if you take out the media query it works just fine, presumably because i set the width to 100%)
Add this also in media query
header button{
right: auto;
left: 695px
}
It will help you to align the button with the text box.
I placed a Container over your input and button, assuming you'll have other elements in the header later.
I then set the section as display: inline-block to make it take the width of the content and also made it position: relative for the child absolute elements. So that those elements will take the section as a starting point and not the header.
https://codepen.io/anon/pen/jGRooL
Just wrap input and button in one parent div and set position relative in it and add width in it.
header {
background: #25b99a;
border-radius: 0 0 10px 10px;
box-shadow: 0px 2px 4px rgba(44, 62, 80, 0.15);
box-sizing: border-box;
height: 80px;
padding: 15px 25px 0 25px;
position: fixed;
top: 0;
width: 100%;
z-index: 5;
}
header input {
background: rgba(255, 255, 245, 0.2);
border-radius: 5px 25px 25px 5px;
border: 0;
box-sizing: border-box;
color: rgba(255, 255, 255, 1);
float: left;
font-size: 15px;
height: 50px;
padding-right: 65px;
outline: none;
text-indent: 15px;
width: 100%;
}
.search-box {
position: relative;
width:100%;
max-width: 700px;
}
.search-box button {
background-color: white;
border-radius: 25px;
border: 0;
cursor: pointer;
height: 50px;
outline: none;
position: absolute;
right: 0;
width: 50px;
z-index: 2;
}
#media screen and (max-width: 767px) {
.search-box {
max-width: none;
}
}
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>
<header>
<div class="search-box">
<input type="text" id="textfield" placeholder="Get it done!" autofocus>
<button id="add"><i class="fa fa-plus" aria-hidden="true"></i></button>
</div>
</header>
Updated Codepen Demo

How to fill the remaining space

I have a horizontal list with 4 items. The first item will be always 52px wide. I want the remaining three items to be equal in width and fill up the remaining space.
How can I do this?
.wa_talents .unlocks {
width: 50px !important;
background: black;
font: normal 20px/52px"Palatino Linotype", "Georgia", "Times", serif;
text-align: center;
}
.wa_talents .tier {
list-style-type: none;
border: 1px solid #221d19;
box-shadow: 0 0 4px #000;
height: 52px;
margin: 5px;
clear: left;
}
.wa_talents .tier li {
float: left;
margin-left: 5px;
width: 30%;
/* THIS FAILS HARD*/
height: 52px;
}
.talent {
background: #000;
}
.talent .cell {
padding: 4px;
margin-top: 2px;
opacity: 0.25;
}
.talent .name {
width: 125px;
text-overflow: ellipsis;
overflow: hidden;
vertical-align: middle;
line-height: 150%;
color: #ffb100;
}
.talent.active .name {
color: #fff;
}
.frame-36 {
height: 36px;
width: 36px;
}
.talent .icon-frame {
display: inline-block;
padding: 1px;
background: #000 no-repeat 1px 1px;
border-radius: 3px;
border: 1px solid #434445;
border-bottom-color: #2f3032;
border-top-color: #b1b2b4;
vertical-align: middle;
margin-right: 5px;
}
.talent.active .cell {
opacity: 1;
}
.talent.active {
background: #5b2200;
border-color: #ce5209;
box-shadow: 0 0 8px #ce5209 inset;
}
<div class="wa_talents">
<div class="tiers">
<ul class="tier">
<li class="unlocks">15</li>
<li class="talent active">
<a href="http://www.google.com" target="_blank">
<div class="cell">
<span class="icon-frame frame-36"></span>
<span class="name">Foo</span>
</div>
</a>
</li>
<li class="talent">
<a href="http://www.google.com" target="_blank">
<div class="cell">
<span class="icon-frame frame-36"></span>
<span class="name">Bar</span>
</div>
</a>
</li>
<li class="talent">
<a href="http://www.google.com" target="_blank">
<div class="cell">
<span class="icon-frame frame-36"></span>
<span class="name">Baz</span>
</div>
</a>
</li>
</ul>
<!-- HERE WILL BE SOME MORE ul#tier LISTS -->
</div>
</div>
View On CodePen
As mentioned before, calc isn't that widely supported. You could use overflow:hidden on an additional div containing the 3 right li's
http://codepen.io/anon/pen/WbVamx
EDIT: wrong pen
Pure CSS : http://codepen.io/saig/pen/EaqBZd
Using JavaScript : http://codepen.io/saig/pen/raXqEJ
var mainId = document.getElementById('main');
var calcWidth = mainId.clientWidth - 52;
var list = document.getElementsByTagName("li");
for(i=0; i < list.length; i++){
if(list[i].classList.contains("talent")){
list[i].style.width=Math.floor((calcWidth/mainId.clientWidth*100)/(list.length-1))-1+"%";
}
}
The simplest solution is to go with calc function. In your case it would be:
.wa_talents .tier li {
float: left;
width: calc((100% - 52px - 20px)/3);
height: 52px;
margin-left: 5px;
}
The rule is a little tricky: 52 is the width of the first li, then you also need to subtract total margin between items (20px).
Support: all major browsers and IE9+.
Demo: http://codepen.io/anon/pen/raXqZG
The only way to do this in pure CSS is using calc(). You can check out the documentation and compatibility table here: https://developer.mozilla.org/en-US/docs/Web/CSS/calc

I want to stick a div left to another div

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.

display anchor tag to full width as a button in HTML?

this is small code for side menu of my page
<div style="display: block;" id="overlay" class="overlay">
<div id="sideMenuGroups">
<div id="sideMenuGroupHeader" class="mSideMenuSeparator">GROUPS</div>
<div id="sideMenuGroupContent" class="mSideMenuContent">
<div id="teacherGroup">As Teacher
<a onclick="groupFeeds();" href="#">Data Mining</a>
<a onclick="groupFeeds();" href="#">Data Structures</a>
<a onclick="groupFeeds();" href="#">C Language</a>
//**display anchor tag to full width of overlay**
<a onclick="groupFeeds();" href="#">Introduction to IT</a>
</div>
</div>
</div>
</div><!--overlay ends here-->
the css for the styles used is
*mSideMenuConten*t has no style defined
mSideMenuContent a- tells how each anchor tag would be visible, i have tried display:table-cell property, but it is not effective for me
overlay tells how the side menu would be
.mSideMenuContent
{
}
.mSideMenuContent a
{
display: table-cell;
height: 37px;
color: #c4ccda;
padding: 3px 0 3px 8px;
font-size: small;
}
.mSideMenuContent a:hover
{
background:#262c3a;
color: #c4ccda;
}
.mSideMenuSeparator
{
background: #434b5c;
border-top: 1px solid #242a37;
border-bottom: 1px solid #242a37;
font-family:Helvetica, sans-serif;
font-size:x-small;
color: #7a8292;
height:17px;
padding-top:4px;
padding-left: 10px;
text-shadow: 0 1px 0 rgba(0, 0, 0, .6)
}
.overlay {
z-index: 1000;
position: absolute;
top: 0;
bottom: 0;
left: 0;
width: 50%;
height: 100%;
background:#31394a;;
color: #c4ccda;
display: none;
}
i want to display the anchor tag to full width of the side menu, how do i do that??
Use this:
display:inline-block;
width: 100%;
By saying inline block, you allow yourself to define a width for the element. Inline elements can't do this be default.
I found display block more convenient. I applied some margin and padding and i got cool/desired output.
display:block;
padding: some padding;
margin: some margin;

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