AngularJs center and resize icon - css

I try to create a grid menu and it looks like below.
My Problem is, that I dont know how to resize the icons, so that they fit, with AngularJs, not with jQuery!
Also I dont know how I can center the icons.
Thanks for your help :)
menu.html
<ion-content id="my_page">
<div class="my_row">
<a class="my_item" href="#/map">
<i class="icon menu_icon ion-android-walk"></i>
</a>
<a class="my_item" href="#/search">
<i class="icon menu_icon ion-android-search"></i>
</a>
</div>
<div class="my_row">
<a class="my_item" href="#/">
<i class="icon menu_icon ion-android-create"></i>
</a>
<a class="my_item" href="#/">
<i class="icon menu_icon ion-android-settings"></i>
</a>
</div>
</ion-content>
css
.my_container{
position: absolute;
top:0;
right:0;
left:0;
bottom:0;
}
.my_row{
height:49.95%;
left:0;
right:0;
background-color:#ffffff;
clear:both;
}
.my_item{
height:100%;
width:49.95%;
background-color:#c0b5b5;
border: 1px solid #ffffff;
float: left;
vertical-align: middle; //dont work :(
text-align: center;
}
i.menu_icon {
font-size: xx-large; //Here i want it to fit, not a final size, but dynamicly
}

Try giving:
i.menu_icon {
font-size: 250%;
}
Here the 250% is relative to the em size and not the height of the parent container. To make them vertically centered, you need to use:
i.menu_icon {
font-size: 250%;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
And finally don't forget to give the parent, position: relative:
.my_row {
height:49.95%;
left:0;
right:0;
background-color:#ffffff;
clear:both;
position: relative;
}

Are you sure you need angular code for this? I think its better to use css instead.
To resize your icons you can use width and height properties for example, or do it with padding. To align your icons you can also use paddings, or margins. Another way is to set position: relative to icon and get it appropriate top value

Related

CSS image alignment difference between firefox and chrome

I can't get my images to align correctly between all browsers:
I'm wondering if it's a border issue?
Question: would the best way to resolve this be to create a media query? Right now I sort of try to find a good middle ground, but when viewed on a safari mobile app, those few pixels make a big difference. Or is there a better way to contain the image between the .mnhouse, .mnsenate, .ushouse, .ussenate1, .ussenate2 divs?
Here is my relevant HTML:
<div id="officials">
<div class='mnhouse'>
<div class="membersublist">
<div class="memberLink"><span id="mnhouselink">Show District <i class="fa fa-external-link-square"></i></span></div>
<div id='housemember' class='lcc_gis_member'></div>
<div id='housedistrict' class='lcc_gis_memberdistrict'></div>
</div>
<img id='housephoto' class='mnhouse_img' src="data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=" width="0" height="0" alt=""/>
</div>
<div class='mnsenate'>
<div class="membersublist">
<div class="memberLink"><span id="mnsenlink">Show District <i class="fa fa-external-link-square"></i></span></div>
<div id='senatemember' class='lcc_gis_member'></div>
<div id='senatedistrict' class='lcc_gis_memberdistrict'></div>
</div>
<img id='senatephoto' class='mnsenate_img' src="data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=" width="0" height="0" alt=""/>
</div>
</div>
And here is my relevant CSS:
#officials img {
height: 100%;
min-height: 87px;
max-width: 65%;
position: relative;
top: -56px;
border:none;
}
.membersublist{
margin-top:15px;
}
.mnhouse, .mnsenate, .ushouse, .ussenate1, .ussenate2 {
height:87px;
background-color: #e6e6e6;
border-top: 1px solid #a7a5a6;
border-right: 1px solid #a7a5a6;
border-bottom: 1px solid #a7a5a6;
border-left: 3px solid #a7a5a6;
}
Here is the demo, in case I miss any relevant code (you need to select a point on the map to open the results).
The issue is your use of negative relative positioning to try to line it up.
#officials img {
...
position: relative;
top: -56px;
...
}
Basically you are positioning it relative to the offset created be the text, which can never be counted upon to be 100% consistent across browsers.
Instead, consider adding positioning to .mnhouse wrapper, and then using absolute positioning to position the images.
.mnhouse {
position: relative;
}
#officials img {
height: 100%;
min-height: 87px;
max-width: 65%;
position: absolute;
top: 0;
border:none;
}

CSS Fixed Position overlapping each other

Basically I'm making a navigation bar and due to Jquery doing a lot of resizing to make a website look 'pretty' I don't want to use a horizontal list and so each button is created like so:
<img src="homeicon.png"><span id="homex"><br /><img src="home.png" /></span>
(yes they're all image buttons for good reason)
but the only problem is they're fixed and set to "top 0" at the top of the page and as a result cannot sit next to each other but rather overlap, any idea on how I can I still keep the position to fixed and they top to 0 yet keep them next to each other?
HTML
<div id="top">
<img src="homeicon.png"><span id="homex"><br /><img src="home.png" /></span>
</div>
CSS
#top a.button { position: fixed; top: 0; padding: 12px; background: url('glacial_ice.jpg'); text-decoration: none; color: black; border-radius: 0px 0px 25px 25px; }
#top { position: relative; top:0; padding-left: 25px; }
Init function (runs on $(document).ready())
$('a.button').animate({
height: '+=5px',
}, 20, function() {
$('a.button').animate({
opacity: 0.6,
height: '-=5px',
}, 20);
});
Thanks
Put them all in a container, i.e. id="header", give the header position:fixed;top:0;etc...
Then, for each of the link/buttons give them:
position:relative;display:inline-block;float:left;
if you want them centered, then in the #header use text-align:center; and remove float:left from the links
So the container will be fixed, but the buttons inside will be relative and not overlap.
hope this helps!
very crude example
http://jsfiddle.net/6SCTZ/
<div id="header">
<div class="button">button1</div>
<div class="button">button2</div>
<div class="button">button3</div>
</div>
CSS:
#header { position:fixed;top:0;width:100%;height:30px;background:black; text-align:center }
.button {position:relative;display:inline-block;color:white;margin:0 5px 0 5px;}
Just put whatever elements need to be fixed within a container element (in this case, I'll use a div with an ID of "top_fixed").
Consider the following html:
<div id='top_fixed'>
<a href='http://google.com'>Google</a>
<a href='http://yahoo.com'>Yahoo</a>
</div>
<div id='tall'></div>
Now, the following CSS:
a { display: inline; }
#top_fixed { position: fixed; top: 0; left: 0; width: auto; }
#tall {height: 2000px; background: #000;}
​
DEMO: http://jsfiddle.net/mHKNc/1/

CSS - Quick Positioning Question

Does anyone know how I'd be able to position the items "videoid" and "timestamp" together? i have them both absolutely positioned so that they go to the bottom right of their container, but I'd like them to display next to each other (video first, followed by timestamp) instead of on top of each other. I've attached a basic idea of my heirarchy and CSS along with an image of what's happening.
<div id="featured_articles">
<ul>
<li>
<a href="LINK">
POST FEATURED IMAGE
</a>
<a href="LINK">
<label>
POST TITLE
<div class="timestamp">
Posted 'X' Days Ago
<div class="videoid"
VIDEO
</div>
</div>
</label>
</a>
</li>
</ul>
</div>
And the CSS:
#featured_articles label .timestamp {
position: absolute;
top: -20px;
right:0px;
background:rgba(0, 189, 246, 0.5);
color: #000;
font-size: 10px;
line-height: 20px;
padding: 0 10px;
text-transform: uppercase;
}
#featured_articles label .videoid {
position:absolute;
bottom:0px;
right:0px;
background:rgba(148, 0, 246, 0.5);
color:#fff;
font-size:10px;
line-height: 20px;
padding:0 10px;
text-transform:uppercase;
}
Here's what's happening on the site:
Can someone please help me out? I think I need to group the two together but I don't know how to approach it from there.
Thanks,
Matt
Change your HTML slightly:
POST TITLE
<label>
<div class="timestamp">
Posted 'X' Days Ago
</div>
<div class="videoid">
VIDEO
</div>
</label>
I'm not entirely sure where POST TITLE should go.
Remove position: absolute on .timestamp and .videoid, and instead:
#featured_articles label {
position:absolute;
bottom:0px;
right:0px;
}
Finally, add float: left to #featured_articles label .timestamp, and overflow: hidden to #featured_articles label .videoid.

Css: Elements with position: relative; wisible trough other elements positioned on top

I have an unordered html list on:
<ul id="maintab" class="shadetabs">
<li class="selected">selected</li>
<li>not selected</li></div>
I need to use position: relative for "selected" items:
.shadetabs li.selected{
position: relative;
top: 1px;
............
}
Everything is OK so far. But now I want to show a div over all other content of website.
<div id="vertical">
<div id="hoz">
content
</div></div>
#vertical{
position:absolute;
top:50%;
margin-top:-198px;
left:0;
width:100%;
}
#hoz{
width:320px;
margin-left:auto;
margin-right:auto;
height:90px;
border:10px solid #BF0000;
background:#f5f5f5;
text-align:center;padding:10px;
}
Unfortunately, this .shadetabs li.selected is visible trough divs "vertical" and "horizontal". I tried to add style="opacity: 1 !important;" to the "vertical" div but it doesn't help.
Give the element a z-index: 2. That way it will be drawn on top of other positioned content.

CSS Float left question

The following code is injected into the page via jQuery. I can't change that, but I can change the css:
<div id="slideshow-prevnext" class="slideshow-prevnext">
<a id="prev" class="left" href="#"><span class="invisible">Prev</span></a>
<a id="next" class="right" href="#"><span class="invisible">Next</span></a>
</div>
I want the three
appear on the left of and the two ("Prev" and "Next") on the right.
How can I do it? I tried float:left but does not work.
Edit: CSS is too long to post. Development site is here at : http://site2.ewart.library.ubc.ca/
The most basic answer:
a.left, a.right { float: right;}
a.dot { float: left;}
In addition, it looks like the stylesheet '/profiles/ubc_clf/themes/logie/style.css' line 37 is trumping your float:
#slideshow-prevnext .left {
background: url(http://site2.ewart.library.ubc.ca/profiles/ubc_clf/themes/logie/images/controller/controller_left_button_on.gif) no-repeat;
**float: left;**
height: 30px;
margin-top: 8px;
text-decoration: none;
width: 29px;
}
If that is to be on the right, it will need to read:
float: right;
In order to accomplish this, you'll need to provide a CSS style which is more specific than the #slideshow-next .left rule. For example, place this in the page <head> tag:
<style type="text/css">
#slideshow-prevnext .left, #slideshow-prevnext .right {
float: right;
}
</style>
Because the <style> tag on the page has a higher precedence than those loaded before it, the rule should override the float value.
I'm not particularly happy with this way of doing things - ideally you should just change the Javascript.
On #slideshow-prevnext add position: relative.
On #slideshow-prevnext .left and #slideshow-prevnext .right remove float: left and add position: absolute.
On #slideshow-prevnext .left add right: 29px and top: 0.
On #slideshow-prevnext .right add right: 0 and top: 0.
On #slideshow-prevnext a.dot add float: left.
It looks like this when you're done:
you can do it by this example.
<div class="wrapper">
<div style="float:left">&nbsp</div>
<div style="float:right;">Prev | Next</div>
<div style="clear:both;"></div>
</div>
i have used Inline Css. You can do it by classes or external Css also.
Without seeing your CSS it makes it hard to guess how you have this working.
Assuming left and right are css classes for floating left/right, just remove them and move the links down like so:
<div id="slideshow-prevnext" class="slideshow-prevnext">
<a id="prev" href="#"><span class="invisible">Prev</span></a>
<a id="next" href="#"><span class="invisible">Next</span></a>
</div>
You'll have to post your CSS if you want a better example.

Resources