问题发生在alpha 6但不是alpha 5
在bootstrap中,3个标签会换行到下一行,这样就可以在较小的屏幕尺寸上使用它们。
在Bootstrap 4中,他们不会包裹并从屏幕的一侧捅掉。这是Bootstrap 4文档中的示例。
如何在bootstrap 3中进行包装?
#viewport
{
width: 200px;
border: 1px solid #000;
}

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" integrity="sha384-rwoIResjU2yc3z8GV/NPeZWAv56rSmLldC3R/AZzGRnGxQQKnKkoFVhFQhNUwEyJ" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.1.1.slim.min.js" integrity="sha384-A7FZj7v+d/sdmMqp/nOQwliLvUsJfDHW+k9Omg/a/EheAdgtzNs3hpfag6Ed950n" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/tether/1.4.0/js/tether.min.js" integrity="sha384-DztdAPBWPRXSA/3eYEEUWrWCy7G5KFbe8fFjk5JAIxUYHKkDx6Qin1DkWx51bBrb" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/js/bootstrap.min.js" integrity="sha384-vBWWzlZJ8ea9aCX4pEW3rVHjgjt7zpkNpZk+02D9phzyeVkE+jo0ieGizqPLForn" crossorigin="anonymous"></script>
<div id="viewport">
<!-- Nav tabs -->
<ul class="nav nav-tabs" role="tablist">
<li class="nav-item">
<a class="nav-link active" data-toggle="tab" href="#home" role="tab">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" data-toggle="tab" href="#profile" role="tab">Profile</a>
</li>
<li class="nav-item">
<a class="nav-link" data-toggle="tab" href="#messages" role="tab">Messages</a>
</li>
<li class="nav-item">
<a class="nav-link" data-toggle="tab" href="#settings" role="tab">Settings</a>
</li>
</ul>
<!-- Tab panes -->
<div class="tab-content">
<div class="tab-pane active" id="home" role="tabpanel">...</div>
<div class="tab-pane" id="profile" role="tabpanel">...</div>
<div class="tab-pane" id="messages" role="tabpanel">...</div>
<div class="tab-pane" id="settings" role="tabpanel">...</div>
</div>
</div>
&#13;
(黑色轮廓显示小视口。在之前的版本中,标签将换行到新行,因此所有内容都在黑线内可见)
答案 0 :(得分:5)
Nav选项卡,与其他组件一样,现在是flexbox。只需使用flex-wrap
。
<ul class="nav nav-tabs flex-wrap" role="tablist">
<li class="nav-item">
<a class="nav-link active" data-toggle="tab" href="#home" role="tab">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" data-toggle="tab" href="#profile" role="tab">Profile</a>
</li>
...
</ul>
http://www.codeply.com/go/hGPyyOv76W
我不认为这是一个问题&#34;而是&#34;设计&#34;。
另一种可能更具响应性的方法是使用flex-column
,但仅限于xs
宽度。这种方式是垂直堆叠而不是包装。
<ul class="nav nav-tabs flex-column flex-md-row" role="tablist">
<li class="nav-item">
<a class="nav-link active" data-toggle="tab" href="#home" role="tab">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" data-toggle="tab" href="#profile" role="tab">Profile</a>
</li>
...
</ul>
答案 1 :(得分:0)
似乎是您正在使用的Bootstrap 4版本的特定问题:
#viewport
{
width: 200px;
border: 1px solid #000;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha/css/bootstrap.min.css" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.1.1.slim.min.js" integrity="sha384-A7FZj7v+d/sdmMqp/nOQwliLvUsJfDHW+k9Omg/a/EheAdgtzNs3hpfag6Ed950n" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/tether/1.4.0/js/tether.min.js" integrity="sha384-DztdAPBWPRXSA/3eYEEUWrWCy7G5KFbe8fFjk5JAIxUYHKkDx6Qin1DkWx51bBrb" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha/js/bootstrap.min.js" crossorigin="anonymous"></script>
<div id="viewport">
<!-- Nav tabs -->
<ul class="nav nav-tabs" role="tablist">
<li class="nav-item">
<a class="nav-link active" data-toggle="tab" href="#home">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" data-toggle="tab" href="#profile">Profile</a>
</li>
<li class="nav-item">
<a class="nav-link" data-toggle="tab" href="#messages">Messages</a>
</li>
<li class="nav-item">
<a class="nav-link" data-toggle="tab" href="#settings">Settings</a>
</li>
</ul>
<!-- Tab panes -->
<div class="tab-content">
<div class="tab-pane active" id="home" role="tabpanel">...</div>
<div class="tab-pane" id="profile" role="tabpanel">...</div>
<div class="tab-pane" id="messages" role="tabpanel">...</div>
<div class="tab-pane" id="settings" role="tabpanel">...</div>
</div>
</div>
答案 2 :(得分:0)
对于Bootstart 4.1.3,不要忘记包含popper.js例如。
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.google.firebase.database.ServerValue;
import com.squareup.picasso.Picasso;
import java.text.SimpleDateFormat;
import java.util.HashMap;
import java.util.Map;
public class PostDetailActivity extends AppCompatActivity {
TextView mTitleTv, mDetailTv, mCategoryTv, mCallTv, rdmTxt;
ImageView mImageIv;
private static final String TAG = "PostDetailActivity";
String user;
String location;
DatabaseReference mRef;
String contact;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_post_detail);
//Action Bar
ActionBar actionBar = getSupportActionBar();
// ActionBar title
actionBar.setTitle("Coupon Details");
// Set Back Button
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setDisplayShowHomeEnabled(true);
// Initialise
mTitleTv = findViewById(R.id.titleTv);
mDetailTv = findViewById(R.id.descriptionTv);
mImageIv = findViewById(R.id.imageView);
mCategoryTv = findViewById(R.id.categoryTv);
rdmTxt = findViewById(R.id.rdmTxt);
mCallTv = findViewById(R.id.callTv);
// get data from intent
String image = getIntent().getStringExtra("image");
String title = getIntent().getStringExtra("title");
String desc = getIntent().getStringExtra("description");
String cate = getIntent().getStringExtra("category");
location = title;
String call = getIntent().getStringExtra("contact");
contact = call;
// Set Data to views
mTitleTv.setText(title);
mDetailTv.setText(desc);
mCategoryTv.setText(cate);
mCallTv.setText(call);
Picasso.get().load(image).into(mImageIv);
}
@Override
public boolean onSupportNavigateUp() {
onBackPressed();
return true;
}
public void redeem(View view) {
new AlertDialog.Builder(this)
.setMessage("Are you sure you want to redeem the voucher?")
.setCancelable(false)
.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
long date = System.currentTimeMillis();
SimpleDateFormat sdf = new SimpleDateFormat("MMM MM dd, yyyy h:mm a");
String dateString = sdf.format(date);
mRef = FirebaseDatabase.getInstance().getReference("/User/" + FirebaseAuth.getInstance().getCurrentUser().getUid());
String key = mRef.push().getKey(); // this will create a new unique key
Map<String, Object> value = new HashMap<>();
value.put("location", location);
value.put("uid", FirebaseAuth.getInstance().getCurrentUser().getUid());
value.put("email", FirebaseAuth.getInstance().getCurrentUser().getEmail());
value.put("timestamp", ServerValue.TIMESTAMP);
value.put("time", dateString);
mRef.child(key).setValue(value);
// DatabaseReference mMasterRef = FirebaseDatabase.getInstance().getReference("/User/" + FirebaseAuth.getInstance().getCurrentUser().getUid() + "/" + key + "/time");
// Log.d("mRef", mMasterRef.toString());
}
})
.setNegativeButton("No", null)
.show();
}
}
目前,W3school example缺少咏叹调控件。这个例子对我有用:
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"></script>
答案 3 :(得分:0)
如果将popper.js,id和aria-controls添加为documented,它似乎可以正常工作:
#viewport
{
width: 200px;
border: 1px solid #000;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" integrity="sha384-rwoIResjU2yc3z8GV/NPeZWAv56rSmLldC3R/AZzGRnGxQQKnKkoFVhFQhNUwEyJ" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.1.1.slim.min.js" integrity="sha384-A7FZj7v+d/sdmMqp/nOQwliLvUsJfDHW+k9Omg/a/EheAdgtzNs3hpfag6Ed950n" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/tether/1.4.0/js/tether.min.js" integrity="sha384-DztdAPBWPRXSA/3eYEEUWrWCy7G5KFbe8fFjk5JAIxUYHKkDx6Qin1DkWx51bBrb" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/js/bootstrap.min.js" integrity="sha384-vBWWzlZJ8ea9aCX4pEW3rVHjgjt7zpkNpZk+02D9phzyeVkE+jo0ieGizqPLForn" crossorigin="anonymous"></script>
<div id="viewport">
<!-- Nav tabs -->
<ul class="nav nav-tabs" role="tablist">
<li class="nav-item">
<a class="nav-link active" id="home-tab" data-toggle="tab" href="#home" role="tab" aria-controls="home" aria-selected="true">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" id="profiles-tab" data-toggle="tab" href="#profile" role="tab" aria-controls="profile" aria-selected="false">Profile</a>
</li>
<li class="nav-item">
<a class="nav-link" id="messages-tab" data-toggle="tab" href="#messages" role="tab" aria-controls="messages" aria-selected="false">Messages</a>
</li>
<li class="nav-item">
<a class="nav-link" id="settings-tab" data-toggle="tab" href="#settings" role="tab" aria-controls="settings" aria-selected="false">Settings</a>
</li>
</ul>
<!-- Tab panes -->
<div class="tab-content">
<div class="tab-pane active" id="home" role="tabpanel" aria-labelledby="home-tab">home</div>
<div class="tab-pane" id="profile" role="tabpanel" aria-labelledby="profile-tab">profile</div>
<div class="tab-pane" id="messages" role="tabpanel" aria-labelledby="messages-tab">messages</div>
<div class="tab-pane" id="settings" role="tabpanel" aria-labelledby="settings-tab">settings</div>
</div>
</div>