html - CSS Pseudo Selector "Blocking" Angular Ng-Click? -
i have css table-card layout uses :before
pseudo selector insert header name.
also in table, created button fires alert when pressed.
the problem button not work in plunkr: http://plnkr.co/edit/zkwekp
but when take css out, buttons work expected.
here's css:
.cards tr:nth-of-type(odd) { background: #eee; } .cards th { background: #333; color: white; } .cards td, .cards th { padding: 6px; border: 1px solid #ccc; text-align: left; } /* force table not tables anymore */ .cards table, .cards thead, .cards tbody, .cards th, .cards td, .cards tr { display: block; } /* hide table headers (but not display: none; accessibility) */ .cards th { position: absolute; top: -9999px; left: -9999px; } .cards tr { border: 1px solid #ccc; } .cards td { /* behave "row" */ border: none; border-bottom: 1px solid #eee; position: relative; padding-left: 20%; } .cards td:before { /* table header */ position: absolute; /* top/left values mimic padding */ top: 6px; left: 6px; width: 45%; padding-right: 10px; white-space: nowrap; } .cards td:nth-of-type(1):before { content: "date"; } .cards td:nth-of-type(2):before { content: "user"; }
the html:
<!doctype html> <html ng-app="app"> <head> <script data-require="angular.js@~1.4.0" data-semver="1.4.0" src="https://code.angularjs.org/1.4.0/angular.js"></script> <link rel="stylesheet" href="style.css" /> <script src="script.js"></script> </head> <body ng-controller="indexcontroller"> <table class='cards'> <tr> <th>color</th> <th>button</th> </tr> <tr ng-repeat="color in pagedata.colors"> <td>{{ color }}</td> <td> <button ng-click="pagefn.clickme()">click me</button> </td> </tr> </table> </body> </html>
and js:
var app = angular.module('app', []); app.controller('indexcontroller', function ($scope) { $scope.pagedata ={}; $scope.pagefn = {}; $scope.pagedata.colors = ['this red. etc... ', 'this green. etc...', 'blue text here... asdfadsfadsfadsf a']; $scope.pagefn.clickme = function () { console.log('hello'); alert('clicked!'); } });
just change css of .cards td:before
this,
.cards td:before { /* table header */ position: absolute; /* top/left values mimic padding */ top: 6px; left: 6px; width: auto; padding-right: 10px; white-space: nowrap; }
width:45%
changed width:auto;
,which preventing button clicked.
Comments
Post a Comment