[英]Change css JQuery doesn't work
i'm trying to change css of class in my HTML. 我正在尝试在HTML中更改类的CSS。 I'm struggling with that already a long time, and I'm not getting what i'm doing wrong.
我已经很久没有挣扎了,而且我没有得到我做错的事。 (I've tried already many versions, but nothing happends)
(我已经尝试了很多版本,但没有发生任何事情)
For example: I would like to change the row height on this following html: 例如:我想在以下html上更改行高:
game.html game.html
<div class="game">
<ul class="each" data-bind="foreach: {data: rows, as: 'row'}">
<li class = "li">
<ul class="row" data-bind="foreach: {data: row.beads, as: 'bead'}">
<li class="bead" data-bind="
currentSide: left,
drag: bead.drag.bind(bead),
></li>
</ul>
</li>
</ul>
app.css app.css
.row {position: relative;
max-width: 3000px;}
game.html game.html
$( document ).ready(function() {
var windowHeight = $( window ).height();
var rowHeight = windowHeight/5;
$('.row').css('max-width', rowHeight);
});
<li class="bead" data-bind="
currentSide: left,
drag: bead.drag.bind(bead)">//Missing closing ", Avoided extra ,
And 和
$('.row').css('max-width', rowHeight + "px");//Add `px`
$( document ).ready(function() {
var windowHeight = $( window ).height();
var rowHeight = windowHeight/5;
$('.row').css('max-width', rowHeight + 'px');
});
This oughta do it.!!! 这个做得好。!!!
You have to append px: 你必须附加px:
$('.row').css('max-width', rowHeight + 'px');
$('。row')。css('max-width',rowHeight +'px');
This will not work: $('.row').css('max-width', rowHeight);
这不起作用:
$('.row').css('max-width', rowHeight);
This will: $('.row').css({maxWidth: rowHeight + 'px'});
这将:
$('.row').css({maxWidth: rowHeight + 'px'});
You're doing: 你在做:
$('.row').css('max-width', rowHeight); // outputs 100
You have to append px
: 你必须附加
px
:
$('.row').css('max-width', rowHeight + 'px'); // outputs 100px
To change the height of the row 要更改行的高度
$('.row').css('max-width', rowHeight);
Needs to be 需要是
$('.row').css('max-height', rowHeight + 'px');
You need to append the px to the value and change max-width to max-height 您需要将px附加到值并将max-width更改为max-height
And you need to change this typo: - 你需要改变这个错字: -
drag: bead.drag.bind(bead),
To: - 至: -
drag: bead.drag.bind(bead)"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.