在移动视图中引导4个独立的卡?

时间:2018-12-02 19:03:21

标签: html css twitter-bootstrap

在移动视图中,引导程序4中的卡分离问题。我尝试使用bottom-margin可以正常工作,但是在桌面视图中,超长机的大小与卡的大小不同。我希望超大屏幕的宽度与三张卡片的宽度相同。

$(document).ready(function() {

	$('.nav-toggle').click(function() {
		var collapse_content_selector = $(this).attr('href');
		var toggle_switch = $(this);
		$(collapse_content_selector).toggle(function() {
			if ($(this).css('display') == 'none') {
				toggle_switch.html('View All');
			} else {
				toggle_switch.html('Close');
			}
		});
	});
});
.jumbotron {
	background-color: white;
}

.card-deck{
    bottom-margin: 10px;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">

<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>

	<section class="selection-portfolio" id="portfolio">
		<div class="container">
			<h1 class="text-center">TEST</h1>
			<h2 class="text-center">Test</h2>
			<div class="row">
				<div class="col-lg-4 col-sm-6 portfolio-item card-deck">
					<div class="card h-100">
						<img alt="team_husky_logo" class="card-img-top" src="">
						<div class="card-body">
							<h4 class="card-title">
							<p class="card-text"></p><a class="btn btn-outline-primary text-center" href=""><i class="far fa-image"></i></a>
						</div>
					</div>
				</div>
				<div class="col-lg-4 col-sm-6 portfolio-item card-deck">
					<div class="card h-100">
						<img alt="ads" class="card-img-top" src="ads">
						<div class="card-body">
							<h4 class="card-title">
							<p class="card-text">But I must explain to you how all this mistaken.</p>
							<p>.</p>
						</div>
					</div>
				</div>
				<div class="col-lg-4 col-sm-6 portfolio-item card-deck">
					<div class="card h-100">
						<img alt="ClickTrack" class="card-img-top" src="">
						<div class="card-body">
							<h4 class="card-title">
							<p class="card-text">But I must explain to you how all this mistaken</p>
						</div>
					</div>
				</div>
			</div>
					<br>
					<h2 class="text-center">All Projects</h2>
					<div class="jumbotron">
						But I must explain to you how all this mistaken
						<hr>
						<div id="collapse" style="display:none">
							"But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of human happiness. No one rejects, dislikes, or avoids pleasure itself, because it is pleasure, but because those who do not know how to pursue pleasure rationally encounter consequences that are extremely painful. Nor again is there anyone who loves or pursues or desires to obtain pain of itself, because it is pain, but because occasionally circumstances occur in which toil and pain can procure him some great pleasure. To take a trivial example, which of us ever undertakes laborious physical exercise, except to obtain some advantage from it? But who has any right to find fault with a man who chooses to enjoy a pleasure that has no annoying consequences, or one who avoids a pain that produces no resultant pleasure?"
						</div><a class="nav-toggle hover-regular" href="#collapse">View All</a>
					</div>


		</div>
	</section><!--portfolio end-->

1 个答案:

答案 0 :(得分:0)

您想要的不是普通的卡片组吗? 您代码中的BS网格标记和.card-deck的混合很奇怪。

$(document).ready(function() {

  $('.nav-toggle').click(function() {
    var collapse_content_selector = $(this).attr('href');
    var toggle_switch = $(this);
    $(collapse_content_selector).toggle(function() {
      if ($(this).css('display') == 'none') {
        toggle_switch.html('View All');
      } else {
        toggle_switch.html('Close');
      }
    });
  });
});
.jumbotron {
  background-color: white;
}

.card-deck {}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">

<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>

<section class="selection-portfolio" id="portfolio">
  <div class="container">
    <h1 class="text-center">TEST</h1>
    <h2 class="text-center">Test</h2>



    <div class="card-deck">


      <div class="card">
        <img alt="team_husky_logo" class="card-img-top" src="https://picsum.photos/400/300?image=20">
        <div class="card-body">
            <h4 class="card-title">
            <p class="card-text"></p>
            <a class="btn btn-outline-primary text-center" href=""><i class="far fa-image"></i> Test</a>
        </div>
      </div>



      <div class="card">
        <img alt="ads" class="card-img-top" src="https://picsum.photos/400/300?image=21">
        <div class="card-body">
          <h4 class="card-title">
            <p class="card-text">But I must explain to you how all this mistaken.</p>
        </div>
      </div>



      <div class="card">
        <img alt="ClickTrack" class="card-img-top" src="https://picsum.photos/400/300?image=22">
        <div class="card-body">
          <h4 class="card-title">
            <p class="card-text">But I must explain to you how all this mistaken</p>
        </div>
      </div>

    </div>

    <h2 class="text-center">All Projects</h2>
    <div class="jumbotron">
      But I must explain to you how all this mistaken
      <hr>
      <div id="collapse" style="display:none">
        "But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of human
        happiness. No one rejects, dislikes, or avoids pleasure itself, because it is pleasure, but because those who do not know how to pursue pleasure rationally encounter consequences that are extremely painful. Nor again is there anyone who loves
        or pursues or desires to obtain pain of itself, because it is pain, but because occasionally circumstances occur in which toil and pain can procure him some great pleasure. To take a trivial example, which of us ever undertakes laborious physical
        exercise, except to obtain some advantage from it? But who has any right to find fault with a man who chooses to enjoy a pleasure that has no annoying consequences, or one who avoids a pain that produces no resultant pleasure?"
      </div><a class="nav-toggle hover-regular" href="#collapse">View All</a>
    </div>


  </div>
</section>
<!--portfolio end-->