margin-left+position:relativeã§submitãã¿ã³ã2ã¤ä¸¦ã¹ãã¨ä¸æ¹ãåä½ããªããªãã±ã¼ã¹
CakePHPã®ããã©ã«ãCSS + $formãã«ãã¼ããã¼ã¹ã«ãposition:relativeãç¨ãã¦submitãã¿ã³ã2ã¤æ¨ªä¸¦ã¹ã«ããããä¸æ¹(å·¦å´)ãæ¼ããªããªãç¾è±¡ãçºçãã¾ãã*1ã
åå ã¯ãsubmitãå«ãdivã®CSSã«ãããã®ã§ããã
CSSã®è¨å®ã«ãã£ã¦ã¯ãCakePHPã«éããçºçããããã¨æãã¾ãã
2/24追è¨
ãã¼ã¹ã®CSSãç§ç¬èªã®ãã®ã®ãããCakePHPããã©ã«ãã®CSSãã使ãã®å ´åãã¬ã¤ã¢ã¦ããå¾®å¦ã«ãããå¯è½æ§ãããã¾ãã
ç¾è±¡
以ä¸ã®ã³ã¼ãã§ãé常æ稿ç¨ã®submitã®ä¸ã«ãæå®URLã«GETã§é·ç§»ããã ãã®Cancelãã©ã¼ã ãåºåã
display:inlineã¨position:relative, top/leftã®æå®ã§æ¨ªã«ä¸¦ã¹ã¾ããã
edit.ctp
<div class="users form"> <?php echo $form->create('User');?> (ä¸ç¥) <?php echo $form->end('Submit');?> </div> <div class="backButton"> <?php echo $form->create('', array('url' => array( 'action' => 'view'), 'type' => 'GET', 'id' => 'CancelButton' )); echo $form->end('Cancel'); ?> </div>
åºåHTMLã½ã¼ã¹
<div class="users form"> <form id="UserEditForm" method="post" action="/users/edit/1"> (ä¸ç¥) <div class="submit"><input type="submit" value="Submit" /></div></form></div> <div class="backButton"> <form id="CancelButton" method="get" action="/users/view/1"><div class="submit"><input type="submit" value="Cancel" /></div></form></div>
é¢é£CSS
(cake.generic.cssç±æ¥) form div.submit { border: 0; clear: both; margin-top: 10px; margin-left: 140px; } (ç¬èª) .backButton { position: relative; top: -43px; left: 120px; display: inline; } .backButton form { display: inline; }
ããã¨ããSubmitããã¿ã³ãã¯ãªãã¯ã«åå¿ããªããªãã¾ããã
CSSã®hoveræå®ã«ããåå¿ãã¾ããã
調æ»
FireBugã®è¦ç´ 調æ»æ©è½ã使ã£ã¦èª¿ã¹ãã¨ã
Cancelãã¿ã³ãå²ãdiv.submit($form->end()ã§èªååºå)ã®é åããSubmitãã¿ã³ãè¦ã£ã¦ãã(ç»åãé»è²é å)äºã«æ°ãã¤ãã¾ããã
form div.submitã«æå®ã®ãmargin-left:140pxã®é åã§ãã
é常表示ã§ã¯è¦ãã¾ãããããã®ãã¼ã¸ã³ãSubmitãã¿ã³ã®ä¸ã«è¦ããã¶ãã£ã¦ããã®ã§ãæ¼ããªãç¶æ ã«ãªã£ã¦ããããã§ãã
å®éã«ãz-indexããã¤ãã¹ã«è¨å®ãã¦ã¿ã*2ã¨ãSubmitãã¿ã³ãåå¿ããããã«ãªãã¾ããã
ããããããã¨ä»åº¦ã¯Cancelãã¿ã³ããSubmitãã¿ã³ã¨ãããå²ãdivã®ä¸ã«ãªã£ã¦æ¼ããªããªãã¾ãã
解決
åå ãå¤ã£ãã®ã§ãCSSã調æ´ãã¾ããã
div.submitãinlineã«ãã¦ãmargin-leftãä¸ããCancelãã¿ã³ãããå°ãå³ã«ãããã¦marginé åã¨ãã¿ã³ãéãªããªãããã«ãã¾ããã
å·®å(CSSã®ã¿)
diff --git a/app/webroot/css/base.css b/app/webroot/css/base.css index 8889c84..8771088 100644 --- a/app/webroot/css/base.css +++ b/app/webroot/css/base.css @@ -356,7 +356,7 @@ form div.submit { border: 0; clear: both; margin-top: 10px; - margin-left: 140px; + margin-left: 35px; } label { display: block; @@ -457,7 +457,8 @@ div.related { .backButton { position: relative; top: -43px; - left: 100px; + left: 120px; + display: inline; }
margin(é»è²)ã®é åããSubmitãã¿ã³ã«è¢«ãããªãããã«ãã¾ããã
ãã¿ã³å ¨ä½ã®ä½ç½®ãå·¦ã«å¯ãã¾ãããå人çã«ããã®ãããã好ã¿ãªã®ã§ ^^;