amp-layout using layout attribute with forms - html

I'm trying to build an amp page for my site.
I am trying to achieve a responsive form with a number of range inputs.
So that when the screen size changes they stack nicely, much as I would when using bootstrap.
The code I have is (as a single example);
<div class="form-field" layout="container">
<div class="form-title" layout="responsive">
<span>How much do you need?</span>
<span [text]="[amount]">
£1500000
</span>
</div>
<div layout="responsive" width="auto" height=100>
<input type="range"
name="amountSlider"
min="10000"
step="10000"
value="1500000"
max="3000000"
on="change:AMP.setState({amount: '£' + event.value})">
</div>
</div>
Now when I add the layout attribute to the div. All elements inside disappear. When I inspect the html it seems to be applying the css;
.i-amphtml-notbuilt, [layout]:not(.i-amphtml-element) {
position: relative;
overflow: hidden!important;
color: transparent!important;
}
Now as far as I can see from reading the docs I am compliant with the amp specification, however I must be doing something wrong here?
Can anyone point me in the right direction as to what I am doing wrong an dhow I Can achieve the layout above?

#Matthew-Flynn
The text was disappearing because of color: transparent!important;. I removed that in the code snippet below. But I'm not sure that answers your positioning question: could you build out this snippet a little more and I'll take a look?
.i-amphtml-notbuilt, [layout]:not(.i-amphtml-element) {
position: relative;
overflow: hidden!important;
}
<div class="form-field" layout="container">
<div class="form-title" layout="responsive">
<span>How much do you need?</span>
<span [text]="[amount]">
£1500000
</span>
</div>
<div layout="responsive" width="auto" height=100>
<input type="range"
name="amountSlider"
min="10000"
step="10000"
value="1500000"
max="3000000"
on="change:AMP.setState({amount: '£' + event.value})">
</div>
</div>

Related

css height different between pages

I am trying to use md-card in a page in my application. I also have an md-autocomplete in my home page. I had to alter the angular-material.css in order to make the autocomplete display perfectly in my home page.
But in my product page where I use md-card, it does not appear properly.
This is the css that makes the product page appear incorrect :
body,
html {
height: 100%; ----> This makes the page incorrect.
position: relative
}
Removing the height makes the other pages incorrect but the product page correct. Hence I need the height attribute in my other pages to display them correctly.
The below is the md-card code:
<div class="container ">
<!-- <div style="margin-top: 5%" flex-sm flex-gt-sm="100" ng-repeat="review in reviews"> -->
<div style="margin-top: 5%" ng-repeat="review in reviews">
<md-card ng-repeat="review in reviews" md-theme="dark-grey" md-theme-watch>
<md-card-title>
<md-card-title-text>
<span class="md-headline">Too Good</span>
<span class="md-subhead">username</span>
</md-card-title-text>
<md-card-title-media>
<div class="md-media-sm card-media">
<img ng-src="{{review
.imgurl}}" alt="">
</div>
</md-card-title-media>
</md-card-title>
<md-card-content class="col-md-11">
<hm-read-more hm-text="{{text}}" hm-limit="100" hm-more-text="read more" hm-less-text="read less" hm-dots-class="dots" hm-link-class="links">
</hm-read-more>
</md-card-content>
<md-card-actions layout="row" layout-align="end center">
<md-button>Like</md-button>
<md-button>Dislike</md-button>
</md-card-actions>
</md-card>
</div>
</div>
My application url : Home page
The product page : Product page
Please help me fix this css issue.
Give background colour to html or remove the height: 100%; for body. Specifying min-height not necessary.
html {
background: #A6333D;
}
body, html {
height: auto;
min-height: 100vh !important;
}
This will do the trick :)

Issue css font-size responsive

I have developed a web page HTML.I wanted to see the behavior of my elements on mobile with Google Chrome mobile emulator.
And I found weird things.
I have this code :
<div>
<div>
<span>config.alarm_vocal_lines_config[1].line_id</span>
<span>1 </span>
</div>
<div>
<span>config.alarm_vocal_lines_config[1].audio_level_line_config</span>
<div>
<span>config.alarm_vocal_lines_config[1].audio_level_line_config.main</span>
<input type="number" value="-90">
</div>
</div>
<br>
</div>
<div>
<div>
<span>config.alarm_vocal_lines_config[2].line_id</span>
<span>2 </span>
</div>
<div>
<span>config.alarm_vocal_lines_config[2].audio_level_line_config</span>
</div>
<br>
</div>
<div >
<div >
<span>config.alarm_vocal_lines_config[3].line</span>
</div>
<br>
</div>
First problem : with this code, in the emulator, the third line is smaller then the other.
Why ? how to avoid it ?
Second problem, if I remove one char from the last line, every line become smaller :
Can someone tell me why the style change and how avoid it?
Not sure if I've made myself clear. Please ask for further clarification.
I haven't any CSS
If its the font size you are concerned about, you could try pasting this into your CSS file (or create one, if you haven't got one)
span {
font-size: 16px !important;
}
You need to add line height for your text.
span {
line-height: normal;
font-size: 16px;
}

How can i get my slideshow to stop changing size?

I can't seem to get my html/css slideshow to stoping changing size. I dont know how else to explain it better then "changing size" so go check it out for yourself:(To get the slideshow to load scroll down on the page then back up) dogmother.ca. I have tried to change some of the CSS to stop it but i cant get it to work same with the html. If anyone has any ideas please tell me as I need to get this fixed as soon as possible.
The index.html slideshow source code:
<div class="slider">
<div class="slider-wrapper theme-default">
<div id="slider" class="nivoSlider">
<img src="images/banner1.jpg" />
<img src="images/banner2.jpg" />
<img src="images/banner3.jpg" />
<img src="images/banner4.jpg" />
<img src="images/banner5.jpg" />
</div>
</div>
</div>
The css for the slide show can be found here:
http://dogmother.ca/css/slider.css
Reading your comments, it sounds like you want to remove the spacing between the navigation and your images. You have styling on the slider. Remove the top margin or change it to the value of your choosing (found in slide.css on your website)
}
.css-slideshow{
position: relative;
max-width: 1586px;
height: 400px;
margin: 0 auto .5em auto;
}

Stack image and text left to right on same row

Hi having some issues here trying to stack image and text on the same line left to right.
<div style="position: absolute; top: 200px; left: 30px;">
<span style="float: left;">
<img class="tglbtn" src="img/toggle_tab_l.png" data-swap='img/toggle_tab_r.png' height="60%" width="60%">
</span>
<p style="float: right; font-size: 20px; color: #92d6f8; overflow: hidden; text-align: left">
Remember User ID?
</p>
</div>
Your Code
http://jsfiddle.net/21Ltsbeb/
Improved
http://jsfiddle.net/21Ltsbeb/1/
I'm not seeing the issue? Though, you might be better off using display:inline-block with matching html elements. Inline as in Have these elements in the same line
.tglbtn {width:60%;height:60%;}
span {display:inline-block;}
p {font-size:20px;color:#92d6f8;overflow:hidden;text-align:left;}
<div>
<span>
<img class="tglbtn" src="http://www.placehold.it/66x66">
</span>
<span>
Remember User ID?
</span>
</div>
Edit
A few things I should note that you need to address as a beginner.
Don't use inline css
Don't use pixels (rem,em,or %)
Avoiding using position absolute
Don't use floats
Remember that good web applications have great continuity in their structure.
Until you get the hang of CSS, I might recommend Foundation's CSS or Bootstrap CSS.
This could be cleaned up a lot for you, and also simplifying your css/removing a lot of the inline styling:
.mind{
display:inline-block;
vertical-align:top;
}
.tglbtn{
height:20px;
}
<div class="wrap">
<img class="tglbtn" src="http://placekitten.com/g/200/300" data-swap='img/toggle_tab_r.png' />
<div class="mind">Remember User ID?</div>
</div>
Set the paragraphs top margin to 0
margin-top:0;
It's being set by the browser default otherwise (I see the mis-alignment in chrome).
See this fixed Example

Image tags in labels with "for" don't respond to clicks in IE7

In a simple setup with an image inside a label:
<input type='checkbox' id='x'>
<label for='x'>click me <img src='http://placedog.com/20/20'></label>
clicks on the image control the checkbox just like clicks on the text in the label or clicks on the checkbox itself, in most browsers. That it doesn't work in IE7 doesn't particularly surprise me, but I'm wondering whether there's some weird IE way of making it work, in that browser.
fake edit hmm apparently it doesn't work in IE8 either.
As discussed in the comments, IE doesn't like this idea. The only way to get around it is with a bit of Javascript - here's an example using JQuery.
$("label img").live("click", function() {
$("#" + $(this).parents("label").attr("for")).click();
});
See http://snook.ca/archives/javascript/using_images_as for a discussion on this.
A little rough and ready, but works without JQuery...
<p>
<input type="radio" id="rb1" value="rb1" />
<label for="rb1">
<img src="image1.png"
onclick="try{document.getElementById('rb1').checked=true;}catch(e){};return true;" />
</label>
</p>
<p>
<input type="radio" id="rb2" value="rb2" />
<label for="rb2">
<img src="image2.png"
onclick="try{document.getElementById('rb2').checked=true;}catch(e){};return true;" />
</label>
</p>
Could be improved, but is fairly resilient as a workaround.
Alternatively you could put an absolutely positioned div spanning the whole width and height of the label. Note though that you have to use IE's opacity filter to make the cover div invisible, because with visibility: hidden it is completely ignored by IE7 and 8.
<style>
.cover{
position: absolute;
left: 0px;
top: 0px;
width: 100%;
height: 100%;
background: yellow;
filter: alpha(opacity=0);
opacity: 0;
}
</style>
<label>
<div class="cover"></div>
<img src="img.png" alt="img" />
</label>